Removing "class name" from all siblings and adding it to the active element in Jquery -


I am working on a menu within which only an active a element should be active Category ( Highly Active ). When I click on any other element, I have to remove the active class from all other a brothers and add it to the clicked link.

This is HTML: -

  & lt; Ul class = "main-links" & gt; & Lt; Li id = "ol" class = "twist" data-id-id = "oli" data-video-flv = "Europe -1. Flv" data-video-m4v = "Europe-1.m4v" & Gt; & Lt; A href = "# ol" class = "very active" & gt; & Lt; Img src = "imgs / btn1.jpg" width = "237" height = "104" style = "margin-right: 3px;" Alt = "" & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li id = "fl" class = "twist" data-id-name = "fl" data-video-flv = "latam-2.flv" data-video-m4v = "latam-2.m4v" & gt; ; & Lt; A href = "# fl" & gt; & Lt; Img src = "imgs / btn2.jpg" width = "237" height = "104" style = "margin-right: 3px;" Alt = "" & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li id = "jo" class = "twist" data-id-name = "joe" data-video-flv = "na-1.flv" data-video-m4v = "na-1.m4v" & gt; ; & Lt; A href = "# jo" & gt; & Lt; Img src = "imgs / btn3.jpg" width = "237" height = "104" style = "margin-right: 3px;" Alt = "" & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; Li id = "ra" class = "twist" data-id-name = "ra" data-video-flv = "sa-1.flv" data-video-m4v = "sa-1.m4v" & gt; ; & Lt; A href = "# ra" & gt; & Lt; Img src = "imgs / btn4.jpg" width = "237" height = "104" alt = "" & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

is that I tried through JQuery: -

  var check_for_main_links = $ (this). Parent (). Attr ('class'); If (check_for_main_links.indexOf ("twist") & gt; = 0) {console.log ($ (this) .attr ('class')); Var $ instant_park = $ (this). Parent (); $ Instant_parent.siblings () RemoveClass ("Active");} var $ elem_name = $ p.attr ('Data-id-name') ($ ('' '' '') ); Var new_position = $ ("#" + $ elem_name). Position () top; //console.log(Element name "+ $ elem_name +" status is "+ new_position);   

You can do this:

  $ ( Click 'ul.main-links li') (funntion () {$ ('ul.main (' a '). AddClass (' too active ');});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -