Setting selected option in with data-content

1 reply · opened Nov 29, 2017

IindigoNov 29, 2017

Hi. I am using the "Customized with Labels" select tag example:
<div class="col-md-6 bottommargin-sm">
<div class="white-section">
<label>Customized with Icons:</label>
<select class="selectpicker">
<option data-icon="icon-glass">Mustard</option>
<option data-icon="icon-signal">Ketchup</option>
<option data-icon="icon-camera3">Relish</option>
</select>
</div>
</div>

How do I set an option using jQuery?

usually it's something like this:
$("#id").val("2").change();
but it's not working (of course I added IDs for the options).

Thanks,
Shani.

SSemicolon WebSTAFFDec 8, 2017

Hello,

This is Definitely Possible!

You can simply select the Value with jQuery using the following code:

jQuery('.selectpicker').selectpicker('val', 'Mustard');

This will definitely work fine. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard