如果找到某个图片,我正在尝试向元标记添加属性。这就是我想要的,我无法弄明白。
更新工作(90%)
<span id="rateitnow">
<img src="/images/icons/stars/5stars.gif">
<meta itemprop="ratingValue" content=" " />
</span>
<script type="text/javascript">
jQuery.noConflict()(function($){
$('#rateitnow:contains("<img border="0" alt="" style="width:61px;height:12px;" src="/images/icons/stars/5stars.gif">")')
$("#rateitnow meta").attr("content", "5");
});
</script>
非常感谢任何帮助!
谢谢,
TWD
答案 0 :(得分:0)
尝试
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var img = $("#rateitnow > img:first");
if(img && img.attr('src') == "/images/icons/stars/5stars.gif") {
$("#rateitnowmeta > meta:first").attr("content", "5");
}
});
</script>