0

Possible Duplicate:
Click trigger on select box doesn't work in jQuery

I am trying to do the following to simulate a click on a select element:

setTimeout(function () {
    $('#' + id).trigger('click');
}, 1000);

This works in Firefox but not IE. Is there some possible work around for IE?

Community
  • 1
  • 1
  • 1
    what is your element id. I suspect its not valid html. The code you posted is fine for IE. – Fresheyeball Aug 12 '12 at 16:29
  • Doesn't work in firefox either. You cannot emulate a click on a select element (as in, to make it open) – Esailija Aug 12 '12 at 16:31
  • @Esailija - That might explain my problems. With my code the way it is I thought it was working. Do you happen to know if you can send any event to a select. For example a mouse event ? –  Aug 12 '12 at 16:33
  • @Anne You can't make it open by itself, sorry. And this doesn't work in firefox for me: http://jsfiddle.net/NmhwQ/2/ If that works for you in firefox then your firefox is different from mine. – Esailija Aug 12 '12 at 16:35
  • Out of interest what's the end goal here? Are you trying to auto select a value from a drop-down? – Chris Moutray Aug 12 '12 at 16:41

1 Answers1

0

Try attaching your custom click event handler, before triggering the click event:

$('#' + id).bind('click', function() {
     alert('clicked');
});
bpatel
  • 381
  • 1
  • 4
  • This works but not what's needed. I would like to send a click event to the select to cause it to open. –  Aug 12 '12 at 16:34