mar*_*dge 2 html wordpress jquery
我正在使用动态生成的菜单系统的WordPress网站,由于未来的更新我无法修改,但我想要做的是能够<span>
在该菜单中更改一个文本的样式jQuery文档准备好了.跨度嵌套为一个<li>
项目,如果这有所不同,我不会.(而且我也没有看到WordPress发挥作用.)还有其他的<span>'s
,我不希望它们改变,所以我需要匹配<span>
我想改变的特定文本.
那么我怎么能改变这个呢 <span>We are here to help.</span>
对此
<span style="color:#123456;">We are here to help.</span>
在 $(document).ready
?
完整的HTML是
<ul id="nav"><li class="li_item"><a class="navlink" href="http://www.mysite.org/contact-us/"><strong>Contact Us</strong><span>We are here to help.</span></a></li></ul>
更新:这有效; 需要将函数包装在别名中以避免冲突:
jQuery(function($) {
$(document).ready(function() {
$("#nav li span:contains('We are here to help.')")
.css("color", "#f8481c");
});
});
Run Code Online (Sandbox Code Playgroud)
试试这个(假设nav
是ul
菜单系统的id ):
$(document).ready(function() {
$("#nav li span:contains('Text text text')")
.css("color", "#123456");
});
Run Code Online (Sandbox Code Playgroud)
对于你的例子,这个jsFiddle工作:
归档时间: |
|
查看次数: |
3171 次 |
最近记录: |