Css Code Is Not Working
I want that when I work on any of the navigation button it will be color red,while the others will be the same color..Here I have the jstl tag..thats why it is not working in jsfid
Solution 1:
When you click on the link you:
- Start some JS
- Modify the DOM of the current page to change the class
- Finish running the JS
- Follow the link
- Discard the DOM you just modified
- Load a new page with a new DOM
If you want to change the classes on the link in the new page, you have to do it either:
- Before sending the page to the client (this could be with server side code or hardcoded into static HTML)
- By checking the
location
with JavaScript, finding the matchinghref
and then modifying that element.
Solution 2:
There are a couple of places that you need to change as a starting point. First in the html, change current to active
<li><ahref="..."class="active">Home</a></li>
and in JS,
$(document).ready(function(e) {
$("ul li a").click(function(){
$("ul li a").removeClass("active");
$(this).addClass("active");
});
});
Post a Comment for "Css Code Is Not Working"