如何删除< style>元素与jQuery? [英] How to remove a <style> element with jquery?

查看:118
本文介绍了如何删除< style>元素与jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以有这个网站,我想更改样式的最新变化,因为我认为它丑陋且无用. 我找到了最坏的部分,但奇怪的是我似乎无法将其删除.

so there is this website and i wanna change the latest change in style, because i think it's ugly and useless. i located the bad part, but strangely enough i can't seem to remove it.

<div id="regularMenu">
<ul class='menu2'>
 <li>
    <a href="/linkA" class="notcurrent">link1</a>
 </li>
 <li>
    <a href="/linkB" class="notcurrent">link2</a>
 </li>
 <li>
    <a href="/linkC" class="notcurrent">link3</a>
 </li>
 <style>
   a, a:visited { color: #832; }
   #menu a, #menu a:visited { color: #832; }
   .menu2 li a, .menu2 li a:visited { color: #832; }
 </style>
</ul>
</div>

我尝试过

 $('.menu2> *:last-child').remove();

 $('/html/body/div[3]/div/ul/style').remove();

那是css路径.我用萤火虫复制了它. 也尝试了复制的Xpath,但:(

that being the css path. i copied it with firebug. also tried it with the copied Xpath but :(

我也尝试过:

 $('a').css("color", "#269");

可行,但它也会覆盖旧的CSS规则.而我宁愿保留它.

that works, but it overwrites the old css rule too. and i would rather have that preserved.

我尝试寻找答案,但找不到任何有帮助的方法.所以现在我希望有人可以帮助我解决这个问题.

i tried looking for an answer but i couldn't find any that helped. so now im hoping someone could help me with this.

谢谢!

推荐答案

您是否尝试过:

$('.menu2 style').remove();

这篇关于如何删除&lt; style&gt;元素与jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆