Link to home
Create AccountLog in
Avatar of erikTsomik
erikTsomikFlag for United States of America

asked on

jquery click problem

When i click on the div with a specific id I am changing the class so it can not be clicked second time. However , the class is being changed but i can still click on the div
$(".btnNotComplete").click(function(){
                  var currentId = $(this).attr('id').substring(5);
                        $('#item_'+currentId).text('');
                  $('#item_'+currentId).text('completed');
                  $('#item_'+currentId).attr('class', 'btnComplete');

})

<div class="btnNotComplete" id="item_1">Mark Complete</div>
Avatar of Gary
Gary
Flag of Ireland image

The class still exists in the dom so use the following which is reacting to changes to the page.

$(".btnNotComplete").on("click",function(){

Edit
That should be on, bad habit
Avatar of erikTsomik

ASKER

it still does not work

http://jsfiddle.net/hgeYs/42/
padas check the link I posted it still does not work
Doh! That's because you have the library set to prototype and  not jquery http://jsfiddle.net/hgeYs/54/
I think I figured out

http://jsfiddle.net/hgeYs/56/
The link I first gave you was fine.  The top line of the js should really be

$(".btnNotComplete").click(function(){
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account