HemantNegi / jquery.sumoselect

A jQuery Single/Multi Select plugin which can be used on almost any device
http://hemantnegi.github.io/jquery.sumoselect
560 stars 287 forks source link

How get only clicked option value #251

Closed mhordii closed 3 years ago

mhordii commented 6 years ago

Hi Hemant,

how i get only clicked option value in multiselect mode? This is my jsfiddle

Thanks

gfukushima commented 6 years ago

I believe you can use the native jQuery selected selector to solve this issue, here's an example of your case:

<select multiple="multiple" placeholder="Hello im from placeholder" class="SelectBox" required> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="mercedes">Mercedes</option> <option value="audi">Audi</option> <option value="bmw">BMW</option> </select>

$('.SelectBox option:seleted')....

This is gonna return all the options selected so you can handle it however you want.

For more details about how the operator works check te link below:

https://api.jquery.com/selected-selector/

maheshKDS commented 6 years ago

@gabrfuk can u explain by 'sumo' plugin because above ur reference not working. its return all value not a single select value

$("#ddlCPT") .change(function () { var str = ""; $("#ddlCPT option:selected").each(function () { str += $(this).text() + " "; }); console.log(str) }) .trigger("change");

its return value when i was select one option as sunday sunday,monday sunday,monday,tuesday etc

Zenoo commented 3 years ago

You can get the select value by using:

$('#yourSelect').val();