Search code examples
jqueryhtmlundefinedclickable

Clickable Jquery Div returns "undefined" if you click directly on text


Thanks in advance for any help. I am using the following code to make an entire li "Clickable". The problem is, if you click on any of the actual text other than the link itself (red, blue & green stats), it returns "undefined". See live link here: http://174.122.31.60/.

$(".available-properties li").click(function(){
 window.location=$(this).find("a").attr("href");
 return false;

});


Solution

  • Just change this:

    $(".available-properties li").click
    

    to this:

    $(".available-properties > li").click
    

    This way you only select the child LI of the available-properties UL element.