使用Javascript根据内容选择和隐藏元素?

时间:2014-01-15 18:15:16

标签: javascript html

我现在正在使用LocomotiveCMS进行项目。有一个为登录用户生成和显示的管理员按钮,但我不希望它在那里。不幸的是,开发人员没有将任何类或ID与按钮相关联,并且所有HTML都是内联的,因此我无法隐藏它。我想知道是否可以使用javascript来定位和隐藏这个元素。这是生成的HTML:

<a href="/products/_admin" onmouseout="this.style.backgroundPosition='0px 0px'" onmouseover="this.style.backgroundPosition='0px -45px'" onmousedown="this.style.backgroundPosition='0px -90px'" onmouseup="this.style.backgroundPosition='0px 0px'" style="display: block; z-index: 1031; position: fixed; top: 10px; right: 10px; width: 48px; height: 45px; text-indent: -9999px; text-decoration: none; background-image: url(http://localhost:8080/assets/locomotive/icons/start.png); background-color: transparent; background-position: 0px 0px; background-repeat: no-repeat no-repeat;">Admin</a>

谢谢!

1 个答案:

答案 0 :(得分:2)

使用jQuery,

$("a[href='/products/_admin']").hide()
相关问题