Hiding specific menu items

隐身守侯 提交于 2020-04-17 22:20:50

问题


I am trying to hide menu items where they contain the word 'Benefits HIDDEN' in a quick launch list. I have been trying to get a script to work, but no avail so far. Using F12 in Edge, the class I want to hide is as follows;

<span class="menu-item-text">Benefits HIDDEN</span>

Which sites under this DIV

<div class=" noindex ms-core-listMenu-verticalBox" id="zz13_idPDPQuickLaunch">

I was trying this kind of approach;

<script>
$(document).ready(function() {
    $(".zz13_idPDPQuickLaunch *:contains('Benefits HIDDEN')").hide ();
});
</script>

But no luck!


回答1:


zz13_idPDPQuickLaunch is ID not a class, use # eg:

<script>
$(document).ready(function() {
    $("#zz13_idPDPQuickLaunch *:contains('Benefits HIDDEN')").hide ();
});
</script>



回答2:


You can use the class/id of element you want to hide as the main part of jQuery selector. If you want to hide the li tag, you can use(static is the class of the li tag):

$(".static:contains('Benefits HIDDEN')").hide();

Best regards,

Amos



来源:https://stackoverflow.com/questions/60988795/hiding-specific-menu-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!