Javascript 在特定容器中查找和更改图像和css
嗯 我在页面上的某个地方有:Javascript 在特定容器中查找和更改图像和css,javascript,jquery,Javascript,Jquery,嗯 我在页面上的某个地方有: <a href="http://www.brand-mark.de/brandimpact/"> <i class="menu_icon fa blank"></i> <span class="menu-text"> <img width="174" height="49" title="XYZ" alt="XYZ" src="http://www.xyz.png"> <noscript><
<a href="http://www.brand-mark.de/brandimpact/">
<i class="menu_icon fa blank"></i>
<span class="menu-text">
<img width="174" height="49" title="XYZ" alt="XYZ" src="http://www.xyz.png">
<noscript><img width="174" height="49" title="XYZ" alt="XYZ" src="http://www.xyz.png"><noscript>
</span>
</a>
并且必须替换“span class=“menu text”“(img和noscript标记)中的所有内容
比如说:
<span class="menu-text">
<img width="200" height="100" title="newtitle" alt="newalt" src="newsrc.png">
<noscript><img width="200" height="100" title="newtitle" alt="newalt" src="newsrc.png"></noscript>
</span>
</a>
如何在jQuery页面加载中实现这一点
$(function(){
$('.menu-text img')
.attr('src','newsrc.png')
.attr('alt','newalt')
.attr('title','newtitle');
$('.menu-text noscript').html($('.menu-text img').clone());
});
您自己尝试过什么吗?使用
.replaceWith()
使用$(“.menu text”).empty()删除所有子项,然后在jquerymuch apprecated中动态创建您想要的!