javascript - disable a link after it's selected -
when click on link gets class named selected after gets class needs disabled until loses class "selected" can't affect other li
without class or class "none"
function abreplanta(idplanta, desc, image){ h = screen.height; if ($('li').hasclass("selected")) { return false; } $('#image_preview').html('<img src="../interface_test/images/loading.gif" />'); $('ul li.selected').removeclass('selected').addclass('none'); $(this).closest('li').addclass('selected').removeattr("disabled"); if(h >= 960){ size = 100; } else if(h < 960){ size = 90; } $.get('2.php', { id_planta: idplanta, size: size }, function(img){ $('#image_preview').html(img); }); $('#description').html(desc); $("#imagezoom").attr("src", "../../images/plantas/sso/" + image); return false; } <li><a href='javascript:void(0);' onclick="return abreplanta.call(this, 2, "text", "image.jpg")"></a></li>
and doesn't work event.preventdefault
i'm using onclick
function
hard tell without seeing more of code, @ glance
change:
if($(this).hasclass('selected')){
to
if($(this).hasclass('selected')){
capital c in hasclass
also, based on edit, right you're checking li
elements in document selected class with:
if ($('li').hasclass("selected")) { return false; }
you should checking li thats wrapping thats clicked if understand you're asking. instead(this assumes idplanta js reference link clicked looks you're trying, can't because code didn't compile in js fiddle when tried build it),
if ($(idplanta).parent().hasclass("selected")) { return false; }
Comments
Post a Comment