Wednesday, December 26, 2018

JQuery event in javascript object



I have a javascript object




function A()
{
this.ini = function()
{
$('#test').html('');
}

$('#click').on('click',function(){
alert('Hi');
});

}


http://jsfiddle.net/G2MUE/1/



But I have a problem, the event onClick is not used.



Thanks for your help


Answer



function A()

{
this.ini = function()
{
$('#test').html('');
}

$(document).on('click', '#click', function(){
alert('Hi');
});
}



http://jsfiddle.net/G2MUE/7/


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...