代码正在使用jquery,我正在尝试将文本更改为带有逗号分隔符的图像标签,因此每个单词我都需要图像标签。在这种情况下,更换图像后,“ 30度冲洗”就消失了。
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
$(document).ready(function() {
$('.pa_wash .attribute-value:contains("iron")').html('<img src="edit.png"/>');
});
</script>
</head>
<body>
<li class="pa_wash">
<span class="attribute-label">Wash : </span>
<span class="attribute-value">30 Degree Wash, iron</span>
</li>
</body>
</html>
$(document).ready(function () {
$('.pa_wash .attribute-value:contains("iron")').html(function () {
return this.innerHTML
.replace("iron", '<img src="edit_0.png"/>')
.replace("30 Degree Wash", '<img src="edit_1.png"/>');
});
});
您需要iron
用图片替换单词,然后html
再次设置。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句