我想在頁面加載時使用jquery顯示selectbox
選項。我已經使用.simulate()
和.trigger
函數,但它不工作,所以你可以請建議一些解決方案。使用jquery打開selectbox選項
代碼:
<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 is not as i need. i want to display option as any 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>
請幫我出從這個問題...
可能重複:http://stackoverflow.com/questions/430237/is-it-possible-to-use-js-to-open-an-html-select-以顯示其選項列表 – ste2425