0
我有一個按鈕元素下面有一個onclick處理程序。在onclick中,我正在構建一個dyanamic查詢字符串。我需要使「模板」變量動態地匹配「模板」選擇菜單中當前所選項目的val()屬性。我怎樣才能做到這一點?jQuery>如何將選擇列表的值傳遞給onclick處理程序?
<select id="template">..select options</select>
<button
type="button"
id="myButton"
onclick="window.open('<?php echo $thePath ?>/test.php?template=?????', 'popup');
return false;">
click me
</button>
我知道我可以搶在jQuery的與$('#template :selected').val();
所選擇的選項我怎樣才能把它傳遞給onclick處理程序?