jQuery Mobile displays hidden select element

一世执手 提交于 2020-01-11 04:51:06

问题


See this select element with display:none. In jQuery Mobile it is displayed despite this:

<select id="dddd" name="dddd"
        data-mini="true" data-native-menu="false" data-theme="c"
        onChange=""
        style="display:none">     
  <option value="1">An optinos</option>
</select>

I'm trying to show/hide jQuery Mobile select elements dependent on other user actions hence why I'm doing the above.

Any ideas?


回答1:


When your page loads, jQuery Mobile enhances your page to have it the mobile look-and-feel. Unfortunately, there is currently an issue with jQuery mobile that it cannot attach custom classes (and even custom styles, by the style attribute) to enhanced elements. Please check https://github.com/jquery/jquery-mobile/issues/3577 for the issue. As a workaround while this issue is still not resolved, you may actually wrap it inside a div element and control the display of the div wrapper instead.

<div id="dddd-wrapper" class="ui-screen-hidden">
  <select data-mini="true" data-native-menu="false" id="dddd" name="dddd" data-theme="c"     onChange="" style="display:none">     
    <option value="1">An optinos</option>
  </select>
</div>

ui-screen-hidden is a jquery mobile defined style rule (in jquery.mobile..css) for hiding an element.



来源:https://stackoverflow.com/questions/11968710/jquery-mobile-displays-hidden-select-element

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