Bug Tracker

Opened 14 years ago

Closed 12 years ago

#4950 closed feature (patchwelcome)

.click(function(){} on option error in IE

Reported by: Dale Owned by:
Priority: major Milestone: 1.4
Component: event Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:


I found an internet explorer bug when performing an onclick function on an <option>

I have code like thus:

var $dropSelectMainCurrent = $('<select></select>').attr('id','dropSelectMainListCurrent'); var $mainListItems2 = $('.linksNameMain_0'); var $mainSelectListValues2 = new Array(); var $mainSelectList2 = new Array(); for (var i=0; i<$mainListItems2.length;i++) {

$mainSelectListValues2[i] = $($mainListItems2[i]).attr("value"); $mainSelectList2[i] = $('<option></option>') .text($mainSelectListValues2[i]) .attr('id','mainLinkOption') .click(function() {

var $thisOptionText2 = $(this).text(); $('.'+$currentDropMenu).html($thisOptionText2+' Drop'); $('#dropSelectChosen').html($thisOptionText2+' Drop'); return false;



} $('#dropSelectMain').append($dropSelectMainCurrent).show();

The click function on this item to be appended works perfectly in Firefox but does not work in IE.

Change History (3)

comment:1 Changed 13 years ago by dmethvin

Component: unfiledevent
Type: bugfeature

Unfortunately, IE doesn't support click events on option elements.


The W3C says it should though:


I'll change this to a feature request.

comment:2 Changed 13 years ago by dmethvin

See also dup #4780 which proposes implementing by hooking the select event and divining how options change.

comment:3 Changed 12 years ago by dmethvin

Resolution: patchwelcome
Status: newclosed

The fix proposed in #4780 seems like it would require too much code to be practical in core, given this is not a critical bug. Anyone with an idea for a succinct patch, please reopen the ticket and we can discuss. All other lurkers, feel free to register here on Trac and vote for this bug using the links at the top of the page.

Note: See TracTickets for help on using tickets.