在我的HTML页面中有这样一个元素:
<a style="display:block;width:728px;height:90px;margin:0 auto;background:#EEE url('/_images/2011images/img_dotco_3.jpg') no-repeat top left; text-decoration:none;color:#000;" href="/domain-registration/dotco-overview.aspx?sourceid=bnrq2co728x90">
<span style="float:right;margin:5px 27px 0 0;width:110px;color:#FFF;text-align:center">
<span style="display:block;font-size:1em;text-align:center">NOW ONLY</span>
<strong style="display:block;font-size:1.6em;text-align:center"><!-- START TAG // Co_RegisterPrice_TLD -->
<span class="Tag_Co_RegisterPrice_TLD"><strong>$35.70</strong>/yr</span>
<!-- End TAG // Co_RegisterPrice_TLD --></strong>
</span>
</a>我需要隐藏它与CSS或Javascript。CSS是最好的方案,但Javascript也可以。事实上,我根本不能编辑HTML代码,所以我没有办法直接删除这个项目。此外,这不是任何其他HTML元素的父元素,所以我找不到一个简单的方法来隐藏它与CSS。
此外,我需要隐藏这个A元素,即使背景图像或链接更改,实际上它并不总是相同的。
我报告了所有可用的HTML。这是一个示例http://subdir.co/help-center/default.aspx,它是上面的横幅。让我知道如何在页面上隐藏它。谢谢。
发布于 2013-01-06 19:31:52
尝试使用jQuery:
$('a[href^="/domain-registration/dotco-overview.aspx?sourceid"]').hide();这将隐藏具有以/domain-registration/dotco-overview.aspx?sourceid开头的href属性的a标记。
发布于 2013-06-30 04:59:35
使用:
document.getElementById('yourElementId').display=none;发布于 2013-01-06 19:29:06
我认为为css选择器添加类或制定一些规则是行不通的,因为元素属性中的定义覆盖了另一个样式定义。如果你使用一些javascript库来进行dom操作,比如jQuery,那将会很容易。
在此之后,您可以编写类似于
$(".sCntSub3 > a").hide()您可以尝试从浏览器控制台查找元素。这是如何验证您选择正确元素的简单方法
https://stackoverflow.com/questions/14181566
复制相似问题