我有一個下拉列表。我想通過點擊按鈕來改變數值。所以它應該經歷所有的值直到最後,然後回到開始。jquery:按鈕經歷下拉值並回到開頭
也每次點擊按鈕,它應該改變innerHTML。
我不知道它是否可能。
所以這是我的下拉HTML:
<div id="masterChart_length" class="dataTables_length">
<label>Show
<select size="1" name="masterChart_length" aria-controls="masterChart">
<option value="10" selected="selected">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="-1">All</option>
</select>
entries</label>
</div>
這是HTML的按鈕使用方法:我發現這個職位Looping through selected values in multiple select combobox JQuery
<button type="button" id="change-dropdown" class="btn btn-primary pull-right">10</button>
但它會顯示所有使用此Jquery的值:
jQuery(function($) {
$('#change-dropdown').click(function() {
$('#masterChart_length > :selected').each(function() {
alert($(this).value()); // using text() here, because the
}); // options have no value..?
});
});
我正在使用Datatables,並且想要更改條目數下拉菜單的工作方式,只需點擊一下按鈕即可。
任何建議或幫助將不勝感激!
你可以把它放在jsfiddle.net嗎? – designtocode
請注意,''HTML'必須SELELECT'有'ID = 「masterChart_length」'它是目前在名稱屬性設置 – Yogesh
的jsfiddle鏈接[這裏](http://jsfiddle.net/sBvjE/2/) – Yogesh