Get Element with jQuery .on()
Posted
by
Gabriel Ryan Nahmias
on Stack Overflow
See other posts from Stack Overflow
or by Gabriel Ryan Nahmias
Published on 2012-07-09T15:10:37Z
Indexed on
2012/07/09
15:15 UTC
Read the original article
Hit count: 182
If I'm using jQuery's .on()
function like this (there's more to it but this is the main problem area extracted):
$(document).on("click", $("#contcont a, #leftnav li a, #leftnav li ul a, #mainarea-home a").not(".secitem-mid a") , function clicker(event, sData) {
var $this = $(this);
sHREF = $this.attr("href");
alert(sHREF);
} );
I'm getting undefined so what would be the best way to actually get the element that's being clicked? I need .on()
so that it always occurs, obviously, instead of having to attach it to all the elements every time new data is loaded (this is through Yahoo! stores so it's a necessity to do it this way). Thanks.
© Stack Overflow or respective owner