2014-01-06 25 views
0

我现在有一个在线商店的购物车这个代码替换文本:jQuery来与图像

<span class="ShoppingList_RemoveCheckBox"> 
<a onclick="document.My_Account_Shopping_List_Detail_Content.rcuid.value="475"; 
document.My_Account_Shopping_List_Detail_Content.FormSubmittedByLink.value="submittedByRemoveLink"; document.My_Account_Shopping_List_Detail_Content.submit(); return false;" href="noURL">Remove </a> 
</span> 

我需要做的是替换图像的“删除”的文字是什么,这样用户就可以点击图片从购物车中删除一件商品。

如何在不影响链接其余部分的功能的情况下做到这一点?

我第一次尝试这种选择的内容:

$(".ShoppingList_RemoveCheckBox").filter(function(){ 
return $(this).html() == "a"; 

要选择的代码,但我不知道是否有只更改文本的方式。我知道那里是.text()Jquery,但是你不需要有一个特定的id来引用它吗?

回答

0
$('.ShoppingList_RemoveCheckBox a').html('<img src="remove.gif" />') 
+0

完美地工作!非常感谢! – laustewa14

1
$("span.ShoppingList_RemoveCheckBox a:contains(Remove)").html($("<img/>", { src: imageURL }));