Javascript Change Class Onclick
Im just trying to get to grips with javascript / ajax / jQuery so Im building a ticket system for my website. Anyway, I have a table at the top of the page; ).on('click', 'a', function(e) {
$('.subtopic a').removeClass('selected'); // remove the class from all the links
$(this).addClass('selected'); // add it to the clicked link
}
Note that I am using the new jquery function .on()
instead of .click, .live or .delegate. The way .on() works, you will make sure you only bind events to the links in the .subtopic row. Using .on() also guarantees your events will still fire when adding new links dynamically to the DOM.
Solution 2:
Solution 3:
Check out.toggleClass(), it does what the name suggests.
Element?
I have a table and I need the cells to have an element posi…
Here's a js fiddle of what I currently have, I am tryin…
So I have a few pictures that I want to randomly generate o…
This is my first question. I usually try to research these …
Right Floated Element Disappears When Using Columns In Firefox
I am using an ol element with column-count and column-gap p…
Setting Link Href From Child Image Src Using JQuery
I am using .wrap() to create a link around each image withi…
How To Limit The Html Table Records In Each Page
I am populating a table in my jsp which has more than 20 re…
I want to show countdown in each of my divs. Right now I ge…
Retain Dynamically Created DropDown List's Selected Value On Event Window.history.back()- JavaScript
Can use the below question as a reference to explain the co…
|
Post a Comment for "Javascript Change Class Onclick"