jquery active menu -
I have a question, I have a menu and I want to add some jquery so that a separate layout in the active menu tab Compared to the rest, here is my code:
& lt; Div id = "menu" & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Div id = "start" & gt; & Lt; Span & gt; Start & lt; / Span & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; Div id = "menuhome" & gt; & Lt; A href = "index.php? Page = home" & lt; Span & gt; Home & lt; / Span & lt; / A & lt; / Div & lt; / Li & gt; & Lt; Li & gt; & Lt; Div id = "menuvoorstellingen" & gt; & Lt; A & gt; & Lt; Span & gt; Voorstellingen & lt; / Span & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; Div id = "menuwinkelwagentje" & gt; & Lt; A & gt; & Lt; Span & gt; Winklevagentage & lt; / Span & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Li & gt; & Lt; Li & gt; Div id = "menucontact" & gt; & Lt; A & gt; & Lt; Span & gt; Contact & lt; / Span & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; / Li & gt;
A tag has a background image that has it to represent the menu button, why do I need to do this when clicking on the button, she got a new background?
Believing your URL will always be the page = [something], and your Divi ID is always the menu [something] Try it: Try setting a variable URL path named
. // You should have '/index.php?page=whatever' // like the next line // alert (url) // it should be alerted to '/index.php?page=whatever'. // If not, then let me know URL = 'http://blah.com/index.php?page=test' match = url.match (/ page = ([\ w] {1,}) /) // This is a regex match // It looks for the string 'page =', // and then the character of any word (letter, number, underscores). // if any '& amp;' , This match will be closed match = match [1] // match is actually an array // the first one passed (index 0) is the whole string, // second (index 1) actual match $ ('.active') In jQuery ,removeClass ('active') // it removes the class, activates anything with a class of active // // basically it resets the page to active $ ('# menu' + Match) should be marked as. AddClass ('Active') // This activates the class, which is the ID of the menu +
and in CSS, activate BG image
Comments
Post a Comment