I need an explanation about a mechanism..
Hi,
this code below shows those both alerts when the option selected in a select widget changes, but, thanks to the last change() it also throws "1" when the page is loaded.
- <select id="jander">
<option id="foo" value=1>1</option>
<option id="bar" value=2>2</option>
</select>
- $('#jander').change(function() {
if ($('#jander').val() == 1)
alert("1");
else
alert("2");
}).change();
This works perfect for me, but..can someone explain the mechanism why the second change() makes to show the alert(1) when the page is loaded?? I don't understand it or I dont find it logical..
Javi