html-select

Hide select option in IE using jQuery

不羁的心 提交于 2019-11-26 02:00:23
问题 Currently I am using jQuery to hide/show select options using following code. $(\"#custcol7 option[value=\" + sizeValue + \"]\").hide(); This works fine in Firefox, but doesnt do any good in other browsers. How to I hide options from select in Chrome, Opera and IE? 回答1: I just came across this and instead of cloning the entire select over and over I just replaced the options that need to be hidden with span elements and hiding the spans ( though the browser didnt visually show them anyway, I

Is there an onSelect event or equivalent for HTML <select>?

。_饼干妹妹 提交于 2019-11-26 01:39:48
问题 I have an input form that lets me select from multiple options, and do something when the user changes the selection. Eg, <select onChange=\"javascript:doSomething();\"> <option>A</option> <option>B</option> <option>C</option> </select> Now, doSomething() only gets triggered when the selection changes . I want to trigger doSomething() when the user selects any option, possibly the same one again. I have tried using an \"onClick\" handler, but that gets triggered before the user starts the

How to style the <option> with only CSS?

烂漫一生 提交于 2019-11-26 01:25:42
问题 Note: This question is not about making a custom dropdown. It\'s only about possibilities of styling <option> elements within the select element in CSS How can I style <option> s of a <select> element with cross-browser compatibility? I know many JavaScript ways which customize the dropdown to convert into <li> , which I\'m not asking about. <select class=\"select\"> <option selected>Select</option> <option>Blue</option> <option >Red</option> <option>Green</option> <option>Yellow</option>

How to style a select tag&#39;s option element?

有些话、适合烂在心里 提交于 2019-11-26 01:24:04
问题 I\'m trying to set the style of an option in a select dropdown menu in Google Chrome. It works in all browsers except IE9 and Chrome. option.red { background-color: #cc0000; font-weight: bold; font-size: 12px; color: white; } <select name=\"color\"> <option class=\"red\" value=\"red\">Red</option> <option value=\"white\">White</option> <option value=\"blue\">Blue</option> <option value=\"green\">Green</option> </select> Without using JavaScript, is there a way to set style to the options in

How to populate a cascading Dropdown with JQuery

拥有回忆 提交于 2019-11-26 00:29:10
问题 i have the following problem: I started to create a form with HTML an JS and there are two Dropdowns (Country and City). now i want to make these two dynamic with JQuery so that only the cities of the selected countries are visible. I\'ve started with some basic JS which worked fine but makes some trouble in IE. Now i\'m trying to convert my JS to JQuery for a better compatibility. My original JS looks like this: function populate(s1, s2) { var s1 = document.getElementById(s1); var s2 =

Is it possible to use JS to open an HTML select to show its option list? [duplicate]

笑着哭i 提交于 2019-11-26 00:04:20
问题 This question already has an answer here: How can you programmatically tell an HTML SELECT to drop down (for example, due to mouseover)? 11 answers Is it possible to use JavaScript to open an HTML select to show its option list? 回答1: Unfortunately there's a simple answer to this question, and it's "No" 回答2: This works on Google Chrome dropDown = function (elementId) { var dropdown = document.getElementById(elementId); try { showDropdown(dropdown); } catch(e) { } return false; }; showDropdown

Hide options in a select list using jQuery

☆樱花仙子☆ 提交于 2019-11-25 23:49:59
问题 I have an object with key/value pairs of options I want to hide/remove from a select list. Neither of the following option selectors work. What am I missing? $.each(results[\'hide\'], function(name, title) { $(\"#edit-field-service-sub-cat-value option[value=title]\").hide(); $(\"#edit-field-service-sub-cat-value option[@value=title]\").hide(); }); 回答1: For what it's worth, the second form (with the @ ) doesn't exist in jQuery 1.3. The first isn't working because you're apparently expecting

Is it possible to style a select box? [closed]

与世无争的帅哥 提交于 2019-11-25 23:48:52
问题 I\'ve got an HTML select box that I need to style. I\'d prefer to use just CSS but if I have to I\'ll use jQuery to fill in the gaps. Can anyone recommend a good tutorial or plugin? I know, Google, but I\'ve been searching for the last two hours and I\'m not finding anything that meets my needs. It needs to be: Compatible with jQuery 1.3.2 Accessible Unobtrusive Completely customizable in terms of styling every aspect of a select box Does anyone know anything that will meet my needs? 回答1: I

Set select option &#39;selected&#39;, by value

耗尽温柔 提交于 2019-11-25 23:32:31
问题 I have a select field with some options in it. Now I need to select one of those options with jQuery. But how can I do that when I only know the value of the option that must be selected? I have the following HTML: <div class=\"id_100\"> <select> <option value=\"val1\">Val 1</option> <option value=\"val2\">Val 2</option> <option value=\"val3\">Val 3</option> </select> </div> I need to select the option with value val2 . How can this be done? Here\'s a demo page: http://jsfiddle.net/9Stxb/ 回答1

Height of an HTML select box (dropdown)

霸气de小男生 提交于 2019-11-25 23:19:11
问题 Can someone confirm that its not possible to change the height of a dropdown that is shown when you click on a select box. The size attribute of the select makes it look like a list, the height attribute in the CSS doesnt do much good either. 回答1: Confirmed. The part that drops down is set to either: The height needed to show all entries, or The height needed to show x entries (with scrollbars to see remaining), where x is 20 in Firefox & Chrome 30 in IE 6, 7, 8 16 for Opera 10 14 for Opera