I have a list of rows containing selects:
<ul>
{% for select in selects %}
<li>
<select id="select-{{ select.id }}">
<option selected disabled>Select value...</option>
{% for value in values %}
<option value="{{ value.id }}">{{ value.name }}</option>
{% endfor %}
</select>
</li>
{% endfor %}
</ul>
I want to have unified jQuery code like:
$(something).onSelect(function(value) {
// use this.id as select id;
// use value as selected value;
return false; // don't change selected item, leave it as 'Select value...'
}
You can use
*in your selector this selects all elements that have the specified attribute with a value containing a given substring and then simply useattr('id'))and.val()to get values from select-box .Demo Code :