dom - How can jQuery show different items based on a variable -


I want to create a navigation bar that CNA is used on every page is the same style in most NAV items, though There is a partial difference in NAV items related to the current page. I want to be able to read a meta tag and use jQuery to display the correct style.

I have pasted my code below - it does not seem to work:

  & lt ;! DOCTYPE HTML Public "- // W3C // DTD XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Meta name = "page-name" content = "about" /> & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; Link href = "frame_styles.css" rel = "stylesheet" type = "text / css" /> & Lt; Script type = "text / javascript" src = "http://jqueryjs.googlecode.com/files/jquery-1.2.6.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Var page name = $ ('meta [name = page-name]'). Attr ("content"); $ (Document) .ready (function () {if (pageName = "about") {$ ('# about') AddClass ('selected');}}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Table range = "0" cell field = "0" cellpadding = "8" & gt; & Lt; TR & gt; & Lt; Td align = "center" bgcolor = "# 0099 cc" & gt; & Amp; Nbsp; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; & Lt; One class = "navLinks" href = "" & gt; Home & lt; / A & gt; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; & Lt; One class = "navLinks" href = "" & gt; News & amp; Amp; Events & lt; / A & gt; & Lt; / TD & gt; & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; An id = "about" class = "navLinks" href = "" & gt; About & lt; / A & gt; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; & Lt; One class = "navLinks" href = "" & gt; Services & lt; / A & gt; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; One class = "new links" href = "" & gt; Irsearch & lt; / A & gt; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" & gt; & Lt; One class = "navLinks" href = "" & gt; Industry & amp; Amp; Government & lt; / A & gt; & Lt; / TD & gt; & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099CC" square = "selected" & gt; Education & amp; Amp; Training & lt; / TD & gt; & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099 cc" & gt; & Lt; A href = "" class = "navLinks" & gt; Multimedia & lt; / A & gt; & Lt; / Td> & Lt; Td align = "center" nowrap = "nowrap" bgcolor = "# 0099 cc" & gt; & Amp; Nbsp; & Lt; / Td> & Lt; / TR & gt; & Lt; / Table & gt; & Lt; P & gt; & Lt; / P & gt; & Lt; / Body & gt; & Lt; / Html & gt; `@ Charset" utf-8 "; / * Css document * / .navlinks {font-family: vardana, geneva, non-serif; Font-size: small; Color: #fff; Text-decoration: none; } Click-link {text-decoration: none; } # Quick-link-table {border-top: 2px solid # 0099CC; Border bottom: 1 px solid # 0099 cc; } .text {font-family: Vardana, Geneva, without-serif; Font-size: small; }. Selected {background: #FFF; Font-family: vardana, geneva, non-serif; Font-size: small; Color: # 000; } 

@core This is working, but change this line: / P> <<> if (page name = "about")

to

  if (page name == " Compared to comparison, you can use the page name like this:  
  $ ("#" + Page name)  . AddClass ("selected");  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -