I look at jquery ui combobox but i could not find it.Where can i right placeholder in source code.
thank you
There is no attribute like input's placeholder for select box dropdown. However, you can create similar effect by using the HTML disabled and selected attribute on a <option> element that has empty value.
To add a placeholder to a select tag, we can use the <option> element followed by the disabled , selected , and hidden attribute. The disabled attribute makes the option unable to select. The selected attribute shows the text inside <option> element opening and closing tags.
A jQuery plugin that enables HTML5 placeholder behavior for browsers that aren't trying hard enough yet. 4k.
The “placeholder” property is used to get or set the placeholder of an input text. This can be used to change the placeholder text to a new one. The element is first selected using a jQuery selector. The new placeholder text can then be assigned to the element's placeholder property.
I made this code for JQueryUI v1.10.2 - 2013-04-17
HTML code:
<select class="combobox" placeholder="123">
<option>...</option>
...
</select>
JS code:
$.widget( "ui.combobox", {
_create: function() {
this.wrapper = $( "<span>" )
.addClass( "ui-combobox" )
.insertAfter( this.element );
this._createAutocomplete();
this._createShowAllButton();
this.input.attr("placeholder", this.element.attr('placeholder'));
},
});
$(function() {
$( ".combobox" ).combobox();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With