$(jQuery).append(newElement)不会触发事件! [英] $(jQuery).append(newElement) does not fire event!

查看:88
本文介绍了$(jQuery).append(newElement)不会触发事件!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个!

我有$(jQuery).append()函数的问题。这是我的函数添加:

  var  newElement = '  < img class =myImgsrc =a.jpg/>'; 
$( #myDiv)。append(newElement);

这里是一个函数句柄新元素(img)。

 $(  .myImg)。click(功能(){
......
});





问题是它没有开火。

如果有这个问题的解决方案除了下面的那个?

  var  newElement = ' < img class =myImgönclick=doFunction( ); src =a.jpg/>'; 

解决方案

(jQuery).append()函数。这是我的函数添加:

  var  newElement = '  < img class =myImgsrc =a.jpg/>'; 


#myDiv)。append(newElement);



当点击一个按钮时调用它。

这里是一个函数句柄新元素(img)。

 


.myImg)。click( function (){
......
});





问题是它没有开火。

如果有这个问题的解决方案除了以下吗?

 < span class =code-keyword> var  newElement = ' < img class =myImgönclick = doFunction(); src =a.jpg/>'; 


hi every one!
i have a problem with $(jQuery).append() function. here is my function add:

var newElement='<img class="myImg" src="a.jpg" />';
$("#myDiv").append(newElement);


it is called when a button click.
and here is a function handle new element (img).

$(".myImg").click(function(){
    ......
});



the problem is that it doesn't fire.
if there any solution for this one except the below?

var newElement='<img class="myImg"  önclick="doFunction();" src="a.jpg" />';

解决方案

(jQuery).append() function. here is my function add:

var newElement='<img class="myImg" src="a.jpg" />';


("#myDiv").append(newElement);


it is called when a button click.
and here is a function handle new element (img).


(".myImg").click(function(){ ...... });



the problem is that it doesn't fire.
if there any solution for this one except the below?

var newElement='<img class="myImg"  önclick="doFunction();" src="a.jpg" />';


这篇关于$(jQuery).append(newElement)不会触发事件!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆