b11 b11 - 1 year ago 208
HTML Question

Cannot change title of Boostrap-select selectpicker

I want to programmatically change the title of my Bootstrap-select selectpicker.

I tried the following JS code which does not work.

.selectpicker({title: 'New title'})

Any other ways I can do this?

Answer Source

Selectpicker will only update if the DOM has been updated. The function below should update title because it lets selectpicker append a new html object (DOM is changed)

function newTitle() {
    var selectpicker = $("#myPicker");
    selectpicker.selectpicker({title: 'New Title'}).selectpicker('render');
    html = '';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download