Monday 30 October 2017

html5 - html select element with default not in the options













I
want to do something like
this:






here's
the rel="noreferrer">jsfiddle.



now I
want the first option the selected one with the content "Choose option" to not be
visible in the dropdown. how can i do that, if that's possible with a select element or
should i do a custom thing.
Thanks in advance.




Answer




You could remove the selected element as soon
as you open the
list:



$('select').click(function
() {
$('option[selected="selected"]',
this).remove();
});


I
am not aware of any native HTML/HTML5 solution.



No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...