jquery - Active link menu switch weird behavior (Bootstrap) -
I'm surprised that there is not a tool to switch bootstrap between So I searched and did some help and tried to apply this script to my menu: This is HTML: It's a strange thing that when I go to I have "debugged" such targets: and It seems that there is nothing wrong in targeting the right elements. What is wrong with the script and why is this strange thing happening? There should be something wrong with your code, as you expected the code posted here is a Bela is: I have removed the falling squares, so it is easy to see in Bella, but it also works with the classes. .active class The various links in the
.nav bar
$ ('new li a'). ('Click', function () {warning ("class added" + $ (this) .Parent (). ('A'). Attr ('href'); $ (This) .Parent ). Parent (). ('Active'). ExitClaim ('active'); $ (this) .Parent (.) AddClass ('active');});
& lt; Nav class = "navbar navbar-default" & gt; & Lt; Div class = "container-liquid" & gt; & Lt; Div class = "navbar-header" & gt; & Lt ;! - blah blah - & gt; & Lt; / Div & gt; & Lt; Div class = "fall navbar-fall" id = "navbar-collapse" & gt; & Lt; Ul class = "nav navbar-nav" & gt; & Lt; Li class = "active" & gt; & Lt; A href = "{{URL :: from ('/')}} & gt; Home & lt; / a & gt; & lt; / li & gt; & lt; li & gt; & lt; a href = "{{URL: From ('/ instructions')}"> Directions
directions class
The active is removed from the
home > and then goes to
directions , but just like half a second, and then it's the first Goes back on the way.
('Click', function () {warning ("clicked" + $ (this) .attr ('href')); alerts ("class removed-> "+ $ (This) .Parent () .Parent (). ('A'). Attr ('href'); Alert (" class added "$ (This) .Parent () ('A'). Attr ('href')); $ (this) .Parent (). Find ('active'). RemoveClass ('active'); $ (this). Parent Output is: Click on AddClass ('Active');});
Directions :
Clicked on http: // localhost: 8000 / directions
http: // localhost: 8000 < Li> class added
ht Tp: // localhost: 8000 / directions
$ ('new li a'). ('Click', function () {$ (this) .Parent () ('active'). Removeclass ('active'); $ (this) .Parent (.) AddClass ('active');}) ;
Comments
Post a Comment