Reputation: 13683
I am trying to hide a div with an id #op-four
using on
instead of live
$("#one").on("click", function() {
$("#op-four").hide();
});
fiddle http://jsfiddle.net/ythSA/ but it wont work
Upvotes: 1
Views: 523
Reputation: 206078
Try with:
$('.links-holder').on('click','#one',function() {
$("#op-four").hide();
});
This use of the .on
method replaces the now deprecated .live()
.
$( document /or/ 'parent_el').on( 'some_event' , 'delegated_element', function(){
Read more: http://api.jquery.com/on
Upvotes: 1
Reputation: 78650
You've placed your code outside of your ready
handler. Move it inside and it works fine.
You were trying to attach a handler to #one
before it actually existed.
Upvotes: 1