HamidRaza
HamidRaza

Reputation: 650

Jquery .on() not working with "e"

working

$('.newbubble').live('click', function(e){
    console.log('clicked');
});

Not Working (here i want to get e.pageX and e.pageY)

$('.newbubble').on('click', function(e){
    console.log('clicked');
});

Again Working this one without "e"

$('.newbubble').on('click', function(){
    console.log('clicked');
});

Can anyone please help me with this, how can i get e.pageX with .on()

Upvotes: 2

Views: 79

Answers (2)

mgraph
mgraph

Reputation: 15338

try

$(document).on('click','.newbubble', function(e){
    console.log('clicked');
});

Upvotes: 2

Shikiryu
Shikiryu

Reputation: 10219

I imagine, .newbubble doesn't exist on DOM ready, so you'll need to delegate.

For example :

$('body').on('click', '.newbubble', function(e){
    // here
});

Read the doc

Upvotes: 7

Related Questions