Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't do this with plain HTML. Check the MDN and official W3C HTML5.x nightly build:</p> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/HTML/Element/select" rel="nofollow">https://developer.mozilla.org/en-US/docs/HTML/Element/select</a></li> <li><a href="http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element" rel="nofollow">http://www.w3.org/html/wg/drafts/html/master/forms.html#the-select-element</a></li> </ul> <p>You really need to switch it out with JavaScript and using the selected attribute on a "fake" option.</p> <p>These are the availabilities of attributes (properties) of the <code>&lt;select&gt;</code> element:</p> <p><em><strong>Global</em></strong></p> <p>accesskey class contenteditable contextmenu dir draggable dropzone hidden id inert spellcheck style tabindex title translate</p> <p><em><strong>Select</em></strong></p> <p>autofocus disabled form multiple name required size</p> <h2>Update</h2> <p>As the OP seemed to allow JavaScript as an alternative, but not jQuery I've added a plain JavaScript example to prepend a empty (selected) option tag;</p> <pre><code>var fakeOpt = document.createElement('option'); var myList = document.getElementById('mySelect'); fakeOpt.selected = 'selected'; myList.insertBefore(fakeOpt, myList[0]); // Listen to a change myList.onchange = function(evt){ var clicked_option = myList.options[myList.selectedIndex].text; if (clicked_option.trim() != '') { console.log(clicked_option); } else { console.log('Empty option selected'); } }; </code></pre> <p>With this there is no need to fill in one by hand in the HTML code.</p> <p>Here's a JSfiddle; <a href="http://jsfiddle.net/VjCbE/3/" rel="nofollow">http://jsfiddle.net/VjCbE/3/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload