Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put a placeholder on jquery ui combobox?

I look at jquery ui combobox but i could not find it.Where can i right placeholder in source code.

thank you

like image 618
eyupatis Avatar asked Aug 06 '12 13:08

eyupatis


People also ask

How to add placeholder for dropdown?

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.

How to make placeholder in select tag?

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.

What is jQuery placeholder?

A jQuery plugin that enables HTML5 placeholder behavior for browsers that aren't trying hard enough yet. 4k.

How to change placeholder text?

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.


1 Answers

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();
});
like image 84
FayGrin Avatar answered Nov 14 '22 22:11

FayGrin