JQuery hide selectMenu?

I am using jQuery selectMenu in a select tag like this.

$('#ddlReport').selectmenu() 

In some cases, I want to hide it, and I cannot figure out how to do it.

this does not work:

 $('#ddlReport').selectmenu().hide(); 

and this one

 $('#ddlReport').hide(); 

is anyone

+6
source share
6 answers

Looking at the demo here and here , it seems that selectmenu works by adding

 <span class="ui-selectmenu-button"> or (probably different selectmenu versions?) <a ... class="ui-selectmenu ..."> 

after the initial selection containing the artificial choice.

You can try to access this with

 $('#ddlReport').next('.ui-selectmenu .ui-selectmenu-button').hide(); 

Although it seems like it can use other classes (instead of -button ). This is also a kind of hacky workaround, and I'm sure the plugin contains some way to allow you to access the recently added menu.

Edit: After looking at the code in the second demo version, it doesn't seem like there is any pre-programmed way to access the new type in this version.

+3
source

Having lost several hours trying to figure it out. I finally wrapped the thing in a <div> and just show / hide in the div. Of course, far from elegant, but it keeps me from mobile mobile devices.

+6
source
  $("#ddlReport").parent().hide(); 

works for me.

+3
source

With new versions of jQueryUI (I work with version 1.11.4) just use the "widget" attribute:

 $("#element").selectmenu( "widget" ).hide(); 
+2
source

Thank you Armatus!

Just want to say that it worked for me:

 $('#ddlReport').next('.ui-selectmenu').hide(); 

Without the .ui-selectmenu-button class, which does not exist in HTML.

+1
source

This is the solution!

 $("#yourSelectId").parent().hide(); 

wrapping with a div or enforcing button classes is ultimately more complicated.

0
source

Source: https://habr.com/ru/post/914749/


All Articles