Reputation: 1
<body>
<form>
<select name="test" id="test">
<option value="one">one</option>
<option value="two">two</option>
</select>
</form>
<button>Open Select Bar</button>
<script src="script.js"></script>
</body>
This is my html codes and I want to open the select list by clicking on the button in jquery, and I am unable to understand that how can I achieve it . Someone suggest me the way to achieve it,
Upvotes: -1
Views: 1184
Reputation: 22323
id
or class
to your button. (For example I give id on snippet.)size
to open your select list using option
and length
when button click.$('#btnselect').click(function(e) {
$('#test').attr('size', $('option').length);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<select name="test" id="test">
<option value="one">one</option>
<option value="two">two</option>
</select>
<button id='btnselect'>Open Select Bar</button>
Upvotes: 0