$('#table').tablesorter({
headers: {1: {sorter: false}}
});
<table id='table'>
<tr>
<th>col 1</th>
<th><select id='something'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
</th>
<th>Col 2</th>
</tr>
</table>
以上代码不允许我点击选择下拉列表并进行选择。我怎么能做到这一点?
答案 0 :(得分:0)
简单,使用更改事件..
$(function(){
$('#something').on('change', function() {
console.log( this.value );
})
});
完全复制的工作代码..
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="jquery.tablesorter.min.js"></script>
</head>
<body>
<table id='table'>
<tr>
<th>col 1</th>
<th><select id='something'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
</th>
<th>Col 2</th>
</tr>
</table>
<script>
$(function(){
$('#table').tablesorter({
headers: {1: {sorter: false}}
});
$('#something').on('change', function() {
alert( this.value );
})
});
</script>
</body>
</html>