Currently I have html like this:
<div class="selector-wrapper">
<label for="product-select-1372104458328-option-0">Style</label><select class="single-option-selector" data-option="option1" id="product-select-1372104458328-option-0">
<option value="Adjustable">
Adjustable
</option>
<option value="Flex Fit">
Flex Fit
</option>
<option value="Trucker Hat">
Trucker Hat
</option>
</select>
</div>
my jquery code is this:
$(function() {
$('.single-option-selector').on('change', function() {
console.log( 'blahblah' );
});
});
the expected result would be for there to be a console.log when the option changes in .single-option-selector however that is not the case I get nothing. No error or anything. Any ideas what I'm doing wrong?
<select>element?$(document).on('change', '.single-option-selector', function () {...});?document. Sincedocumentis always present at runtime, we will always be able to catch theonchangeevent bubbling up. However, using$(document)incurs a performance overhead: I'll detail that in a followup answer.