<!DOCTYPE html>
<head>
</head>
<body>
<select name="food">
<!-- The following line makes a placeholder -->
<option value="" disabled selected hidden>select food</option>
<option value="apple">apple</option>
<option value="melon">melon</option>
</select>
</body>
$(".js-example-placeholder-single").select2({
placeholder: "Select a state",
allowClear: true
});
// A non-CSS - no JavaScript/jQuery answer:
// add option and disable it, it will act like placeholder.
<select>
<option value="" disabled selected>Select your option</option>
<option value="optionA">optionA</option>
</select>
//The Javascript
$('select').select2({
minimumResultsForSearch: -1,
placeholder: function(){
$(this).data('placeholder');
}
});
//Add this in HTML
<select data-placeholder="Your Placeholder" multiple>
<option></option>
<option>Value 1</option>
<option>Value 2</option>
<option>Value 3</option>
<option>Value 4</option>
<option>Value 5</option>
</select>
// disabled hidden play as a role of placeholder, as select input dosn't have placeholder
<select name="monthname" required>
<option value="" selected disabled hidden>Select Month</option>
<option value="Jan">January</option>
<option value="Feb">February</option>
<option value="Mar">March</option>
<option value="Apr">April</option>
<option value="May">May</option>
<option value="Jun">June</option>
<option value="Jul">July</option>
<option value="Aug">August</option>
<option value="Sep">September</option>
<option value="Oct">October</option>
<option value="Nov">November</option>
<option value="Dec">December</option>
</select>
<select style='color:gray' oninput='style.color="black"'>
<option style='display:none'>
Choose an option
</option>
<option>
1
</option>
<option>
2
</option>
<option>
3
</option>
</select>
<option value="" selected disabled hidden>Select Here</option>
<option default>Select Your Beverage</option>
Code Example |
---|
Html :: bootstrap modal remove gray background |
Html :: textarea html break line |
Html :: insert svg file in html with animation |
Html :: bootstrap 5 background color |
Html :: html small tag |
Html :: circlular waiting icon bootstrap |
Html :: how to collect input textbox in html |
Html :: html signature |
Html :: two divs in the same place |
Html :: html code contact form template |
Html :: how can i make a quote element in html |
Html :: rating star |
Html :: html a |
Html :: style tag html |
Html :: html always show scrollbar |
Html :: input month in html |
Html :: html typing shortcuts |
Html :: underline text in html |
Html :: a tag new page] |
Html :: bootstrap class width auto |
Html :: how to add an ident in html |
Html :: favicon.ico html |
Html :: description list html |
Html :: google share link html |
Html :: responsive svg image in html |
Html :: how to add an svg image to html |
Html :: html link anchor external page |
Html :: html5 comment |
Html :: p tag in html |
Html :: html img onclick |