Luis Valencia
Luis Valencia

Reputation: 34038

Hiding dropdown with jquery is not working

In a Sharepoint site I need to hide a dropdown list that appears on the ribbon, the following code does not throw any error but the dropdown is not hidden, I also tried .hide

A screenshot: http://screencast.com/t/c8JXLH03

My code:

$( document ).ready(function() {
    $("span#Ribbon.Tabs.InfoPathListTab.Views.ddViews-Medium").css('display', 'none');
});

The html generated of that elemnt.

<span class="ms-cui-dd" id="Ribbon.Tabs.InfoPathListTab.Views.ddViews-Medium" unselectable="on" mscui:controltype="DropDown"><span class="ms-cui-dd-text" style="width: 100px" unselectable="on"><a>Nuevo</a></span><a class="ms-cui-dd-arrow-button" id="Ribbon.Tabs.InfoPathListTab.Views.ddViews" unselectable="on" href="javascript:;" onclick="return false;" aria-haspopup="true" aria-describedby="Ribbon.Tabs.InfoPathListTab.Views.ddViews_ToolTip"><span class=" ms-cui-img-5by3 ms-cui-img-cont-float ms-cui-imageDisabled" unselectable="on"><img class="" style="top: -35px;left: -27px;" unselectable="on" src="/_layouts/15/3082/images/formatmap16x16.png?rev=23"></span><label class="ms-cui-hidden" unselectable="on">Vistas</label></a></span>

Upvotes: 2

Views: 141

Answers (2)

Josh Crozier
Josh Crozier

Reputation: 241198

You could also use an attribute selector rather than escaping the . characters.

$('span[id="Ribbon.Tabs.InfoPathListTab.Views.ddViews-Medium"]').hide();

Example Here

Upvotes: 3

Rory McCrossan
Rory McCrossan

Reputation: 337714

The . characters in the id need to be escaped so that they are not interpreted as a class selector:

$(document).ready(function() {
    $("#Ribbon\\.Tabs\\.InfoPathListTab\\.Views\\.ddViews-Medium").hide();
});

Upvotes: 5

Related Questions