javascript - Open selectbox option using jquery -
i want show selectbox
option using jquery when page loads. have used .simulate()
, .trigger
function it's not working, can please suggest solution that.
code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="simulate.js"></script> <script> $(document).ready(function(){ $("#test").simulate('mousedown'); // not working $("#test").trigger('click'); // not working //$("#test").attr('size',3); // size not need. want display option dropdown shows. }); </script> <select id="test"> <option value="0">select option</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select>
please me out problem...
try this...
$(document).ready(function(){ var mydropdown=$("#test"); var length = $('#test> option').length; mydropdown.attr('size',length); $("#test").click(function(){ mydropdown.attr('size',0); }); });
Comments
Post a Comment