admin管理员组

文章数量:1323714

I am having an issue with a jquery function. It works in FF but not in IE 6. I want the function to be triggered when any option inside a select drop down is clicked. Here is the start of my funcation:

$('#titleSelect option').click( function() {    
    alert("title clicked");
    ......
});

Here is my drop down list:

<select id="titleSelect">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>

So in FF, the alert is triggered but in IE it is not. Is there any sort of an issue with IE recognizing the click event on a select and if so is there any way around it.

I am having an issue with a jquery function. It works in FF but not in IE 6. I want the function to be triggered when any option inside a select drop down is clicked. Here is the start of my funcation:

$('#titleSelect option').click( function() {    
    alert("title clicked");
    ......
});

Here is my drop down list:

<select id="titleSelect">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>

So in FF, the alert is triggered but in IE it is not. Is there any sort of an issue with IE recognizing the click event on a select and if so is there any way around it.

Share Improve this question asked Sep 28, 2009 at 12:34 CarolineCaroline 9693 gold badges17 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

why you don't use the onChange event? like:

$('#titleSelect').change( function() {    
alert("title "+$(this).val()+" clicked");
......
});

the jQuery change-event documentation you can find here:

http://docs.jquery./Events/change#fn

If you look at this page, go to the bottom, the Applies To section, and you can see that the option element is not in the list.

http://msdn.microsoft./en-us/library/ms536913%28VS.85%29.aspx

If you really want an event on the option element then look at the events on this page (click on the word events in the table): http://msdn.microsoft./en-us/library/ms535877%28VS.85%29.aspx#

Otherwise, just react to the onchange event on the select element and you will know when something is changed, but, that means that if they click on the event that was already selected then no event will fire.

本文标签: javascriptJqueryissue with click event on Select dropdowin in IE6Stack Overflow