点击事件不会在javascript中触发 [英] On click event is not fired in javascript
问题描述
亲爱的专家,
我用jquery打印了一些html内容..这是下面的代码....
< pre lang =Javascript> $( #cart-grid)。append( < tr class ='cart_table_item'> +
< td class ='product-remove'> +
< a href =''class ='删除'title ='删除此项'>
< i class ='icon-remove'> ;< / i>< / a>< / td> +
< td class ='product-thumbnail'> +
< a href ='Item_desc.aspx?itmid = + _itemID + '> +
< img width ='90'height = '90'src = 'wp-content / uploads / 90x90 / + _picName + 'class ='attachment-shop_thumbnail wp -post-image'/> +
< / a>< / td> +
< / tr>)
});
这是下面的一段javascript代码,用于从上面打印的内容中删除一个表格行....
< pre lang =Javascript> $( 。删除)。on( 点击, function (e){
alert( asd);
var href = $( this )。attr(' href');
$( this )。nearest( tr)。remove(); // 删除行
返回 false ;
});
但是当我点击删除链接时,上面的事件将不会被解雇....当我硬编码然后事件将是解雇.....
请帮助我..
谢谢和问候,>
Dileep
( # cart-grid)。append( < tr class ='cart_table_item'> +
< td class ='product-remove'> +
< a href =''class ='remove'title ='删除此项'>
< i class ='icon-remove'>< / i>< / a>< / td> +
< td class ='product-thumbnail'> +
< a href ='Item_desc.aspx?itmid = + _itemID + '> +
< img width ='90'height = '90'src = 'wp-content / uploads / 90x90 / + _picName + 'class ='attachment-shop_thumbnail wp -post-image'/> +
< / a>< / td> +
< / tr>)
});
这是下面的一段javascript代码,用于从上面打印的内容中删除一个表格行....
< pre lang =Javascript>
( 。remove)。on( 点击, function (e){
alert( asd);
< span class =code-keyword> var href =
( this )。attr(' href');
Dear Experts,
I have print some html content using jquery.. Here is the Below code....
$("#cart-grid").append("<tr class = 'cart_table_item'> " +
"<td class='product-remove'> " +
"<a href='' class='remove' title='Remove this item'>
<i class='icon-remove'></i></a></td> " +
"<td class='product-thumbnail'> " +
"<a href='Item_desc.aspx?itmid=" + _itemID + "'> " +
"<img width='90' height='90' src='wp-content/uploads/90x90/" + _picName + "' class='attachment-shop_thumbnail wp-post-image' /> " +
" </a></td> " +
"</tr>")
});
And here is the below piece of javascript code to remove a table row from the above printed content....
$(".remove").on("click", function (e) {
alert("asd");
var href = $(this).attr('href');
$(this).closest("tr").remove(); // remove row
return false;
});
But when i clicked the remove link then the above event will not be fired.... when i hard coded then the event will be fired.....
PLease Help me..
Thanks and Regards,
Dileep
("#cart-grid").append("<tr class = 'cart_table_item'> " + "<td class='product-remove'> " + "<a href='' class='remove' title='Remove this item'> <i class='icon-remove'></i></a></td> " + "<td class='product-thumbnail'> " + "<a href='Item_desc.aspx?itmid=" + _itemID + "'> " + "<img width='90' height='90' src='wp-content/uploads/90x90/" + _picName + "' class='attachment-shop_thumbnail wp-post-image' /> " + " </a></td> " + "</tr>") });
And here is the below piece of javascript code to remove a table row from the above printed content....
(".remove").on("click", function (e) { alert("asd"); var href =
(this).attr('href');
这篇关于点击事件不会在javascript中触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!