![](/img/trans.png)
[英]How to bind a javascript function to dynamically added Element on DOM?
[英]How to bind facebox object dynamically with dom element
function test()
{
//load some data through ajax call
html = '<a rel="facebox_edit" href="www.google.com">abc</a>';
$('#id_fv').html(html);
}
jQuery(document).ready(function($) {
$('a[rel*=facebox_edit]').facebox({
loadingImage : full_path+'images/loading.gif',
closeImage : full_path+'images/closelabel.png'
});
});
在加载身体时,我调用函数test(),现在,当我单击链接时,它将直接转到www.google.com页面,而不是将其加载到facebox中。 怎么解决呢?
这样写..
function test()
{
//load some data through ajax call
html = '<a rel="facebox_edit" href="www.google.com">abc</a>';
$('#id_fv').html(html);
}
jQuery(document).ready(function($) {
test();
$('a[rel*=facebox_edit]').facebox({
loadingImage : full_path+'images/loading.gif',
closeImage : full_path+'images/closelabel.png'
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.