0

Here is the issue, which one I am not able solve. In my page, I am having a select menu. Beside the select menu, one button. What I want is, when I click the button, the select menu will open. Here is the code which one I started.

$('#myButton').click(function () { $('#mySelect').bind('mousedown', function () { console.log('foo'); }); $('#mySelect').trigger('mousedown'); }); 

Here is the jsbin link. http://jsbin.com/Odeyocof/2/edit?html,js,output

1

1 Answer 1

0

There is no default method to open a select element in JavaScript. But There is a different way to accomplish this task :

$('#myButton').click(function(){ $('#mySelect').show(); $('#mySelect')[0].size=2;/* Choose a size that's perfect */ }); /* Hide Select Menu when user clicks an option */ $('#mySelect').live("click",function(){ $('#mySelect').hide(); }); 

Source

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.