Reputation: 63
I have this code
<select id="priority" onchange="myfunction(10);">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
and what i don't understand that it does not trigger the event on the change of the select tag. Why is that?
Upvotes: 0
Views: 139
Reputation: 4038
If you want to stick to your own code, then you have to change the handler on jsFiddle as mentioned by @Pointy. But if you want it to be done in another way, then try it as below.
javaScript :
priority.onchange = function myfunction()
{
alert("On change worked");
}
jQuery :
$("#priority").change({id : 10}, function(event){
alert(event.data.id);
});
Upvotes: 1
Reputation: 413682
You've told jsfiddle to put your JavaScript code inside a "load" handler. Thus, your function isn't global and won't be found when the element changes.
Change the pulldown that currently says "onLoad" to either "no wrap (head)" or "no wrap (body)".
Upvotes: 1