php - JQuery removing and adding classes -
I am trying to use JQuery to add / remove classes as part of a function that is main
Here is my javascript:
$ (document) .ready (function () {var clickHandler = function ( $ ('. (' 'Selected'). $ ('Selected'); $ (this) .addClass ('selected' '($.' 1 '), clickhandler); $ (' link2 ' ). Bind ('click', {id: '2'}, clickhandler); $ ('link3'). I have divs HTML (this part works):
& lt; div id = "options_1" class = "tab" & gt; & lt; h3 & gt; your feed & lt; / h3 & gt; & lt;? = $ UserFeed? & Gt All recent activity $ Feed? & Gt; & lt; / div & gt; & lt; div id = "options_3" class = "tab" & gt; & lt; h3 & gt; Trends & lt; / H3 & gt; coming soon! & Lt; / Div & gt; And here's the HTML of the link in the sidebar section of the page that controls the div switching. The "selected" category should be removed from Option 1 and added to all the user selected links, but this is not happening. The square is not being changed at all.
& lt; Ul id = "feedOptions" & gt; & Lt; Li & gt; & Lt; A href = "#" id = "1" class = "link 1" class = "selected" & gt; Your feed & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "2" square = "link 2" & gt; All activity & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "#" id = "3" square = "link 3" & gt; Trends & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;
As I said above, I can not change the 'selected' square at all. Any suggestions?
You have multiple classes
attributes on the same element, rather than its:
& lt; A href = "#" id = "1" class = "link1" class = "selected" & gt; Your feed & lt; / A & gt;
You should have it (a feature, different classes with location):
& lt; A href = "#" id = "1" class = "link 1 selected" & gt; Your feed & lt; / A & gt;
Comments
Post a Comment