Hello, I'm new in jQuery. I wrote simple code to add then remove Class after Click Close button but it not working.
First, you need click on div.item, after that, when I click Close, every will return original. I read delegate the events by on() method but donot know how to use in my case.
Here is my Fiddle:
http://jsfiddle.net/gaoshun92/t2TxH/
- $(document).ready(function(){
- $("div.item").click(function() {
- $(this).addClass("open");
- $(this).find("a.close").removeClass("hide");
- });
- $("a.close").click(function() {
- $(this).addClass("hide");
- var current = $(this).closest('div.item');
- $(current).removeClass("open");
- });
- });