Can't seem to gobble up these nested images in jquery for event handling -
note: version of jquety working not support ".on". also, want li clickable.
note: did additional testing , capturing li's on page, within ul in question, none of li's allow delegate or live work. not it.
basically have lot of list items, , there no real way grab these li elemenets because there no unique id's assigned. try match on "partial id", i've tried.
the weird thing is, having success when not using ".live" or ".delegate". example, if use ".bind"... can @ them.
what odd: in ".live" tries can elements. but, clicking on them nothing. so, see them in basket (when console them), clicking on them nothing.
i have structure - ul > li surrounded many divs. (just give idea data structure dense).
<li id="item_111190897"> <span class="shoecolor" style="display:none">blue converse</span> <span class="shoecolor"> <a class="shoepopup" data-popup-ref="#shoe_item_111190897" href="javascript:;"> <img class="available" src="/media/available.gif" alt=""> </a> <span class=""> <img alt="" src="shoeicon.png"> </span> blue converse available now! </span>
basically, there bunch of these li's - , no discernable thing hook onto, trying following: not work!!!
$(document).delegate("li:has(.available)", "click", function(){ // }) $(document).delegate("li[id^='item_']", "click", function(){ // }) $(document).delegate(".available.closest('li')", "click", function(){ // }) $('li:has(.available)').live("click", function(){ // })
tried alot more permuations ".live"...
but ---> ".bind" works. works.
$('li:has(.available)').bind("click", function(){ // })
any advice?
try this:
$(document).on("li:has(.available)", "click", function(){ // });
edit: based on edited question, replace on
delegate
:
$(document).delegate("li:has(.available)", "click", function(){ // });
here working jsfiddle example.
you forgot .
before available
class name.
note: if you're using jquery
version greater 1.7
, should use on
.
Comments
Post a Comment