145
rated 0 times
[
152]
[
7]
/ answers: 1 / hits: 16506
/ 9 Years ago, tue, december 8, 2015, 12:00:00
I have the following HTML code :
<select name=test123 id=test123 onchange=testOnchange()>
<option>Chocolate</option>
<option>Candy</option>
<option>Taffy</option>
<option>Caramel</option>
<option>Fudge</option>
<option>Cookie</option>
</select>
<script>
$( #test123 ).change(function() {
console.log(change);
});
function testOnchange() {
console.log(onchange);
}
</script>
If I use JS to set a value for the select like this:
$(#test123).val(Candy);
why does testOnchange()
trigger, but jQuery change
doesn't?
What exactly is the difference between change
and onchange
?
More From » jquery