嘿,我想知道如何检查复选框的ID.
这是我的HTML最初看起来可能是这样的:
<div class="check_filter">
<div id="filter">
<input type="checkbox" id="check1" /><label for="check1">Marketing</label>
<input type="checkbox" id="check2" /><label for="check2">Automotive</label>
<input type="checkbox" id="check3" /><label for="check3">Sports</label>
</div>
</div><!-- End check_filter -->
Run Code Online (Sandbox Code Playgroud)
我假设jQuery看起来像这样:
$(document).ready(function() {
$(":checkbox").click(function(){
var id = $(this).attr('id');
$.post("index.php", { id: id });
//return false to ensure the page doesn't refresh
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试获取已检查的项目ID,然后在mysql查询中发布该ID以从数据库中获取id的结果.
感谢您的帮助.