b11 b11 - 6 months ago 47
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?


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 = '';