After clicking on the labels are populated from the database, the label needs to be red and bold when another If the label is clicked, the label must first return to the original state and the new label must be active and it should be bold and red for some reason, the changectivets () works only for the first 2 labels, that is, When first click on the label When it gets red, it gets red and when the second label is clicked, the first label becomes black and the second label becomes red when the third label is clicked, the second label is red and the third person is red How do I fix this?
Here is the code:
& lt; Html & gt; & Lt; Period & gt; & Lt; Input type = "hidden" name = "leebfilter" id = "idLib & lt;% = liabkey% & gt;" Value = "& lt;% = liabkey%>" / & Gt; & Lt; Div & gt; & Lt; Label = "idLib <% = liabkey%>" Id = "liablabel" style = "cursor: hand; padding-left: 25px; font-weight: normal" onClick = "clearLiabFilter (); document. GetElementById ('idLib & lt;% = liabkey% & gt;' ). Check = true; Variable Stats (this); "& gt; & Lt;% = liab.getName ()%> & Lt; / Br & gt; & Lt; / Labels & gt; & Lt; / Div & gt; & Lt; / Span & gt; & Lt; Style type = "text / css" & gt; .activate {font-weight: bold; Color: # E 40000;} Visited {font-weight: normal; Color: # 000000;} & lt; / Style & gt; & Lt; Script & gt; Id (id) by return function {return document. GetElementById? Document.getElementById (ID): document.all [id]; } Var prevLink = ""; Function changesActivestats (AI) {if (prevLink) by IID (PRLL) .className = ''; Ele.className = 'active'; PrevLink = ele.id; } & Lt; / Script & gt; & Lt; / Html & gt;
Are you against JQuery?
If not, then it should work. $ ('label'). Click (function () {$ ('label'). RemoveClass ('active'); / * Remove 'active' class from all labels * / $ (this) .addClass ('active'); / * Click the 'active' square for)}; Edit: Edit: JQuery has not been used before a little more detail as the interpreter.
And so it should be loaded before you can do all the nifty stuff.
& lt; Head & gt; & Lt; / Head & gt; Add the following tags: & lt; Script src = "http / / ajax.googleapis.com / ajax / libs / jquery / 1.7.2 / jquery.min.js" type = "text / javascript" & gt; & Lt; / Script & gt; ()
Then between the tags, but after the script tag above, add the following:
$ ( Document)). (Function () {$ ('label') (function () {$ ('label'). RemoveClass ('active'); / * Remove 'activate' class from all labels * / $ (this). Click the 'Active' class to addClass ('active'); / * click}};}); ()
Comments
Post a Comment