0
這裏是我的HTML源代碼:jQuery選擇問題
<ul id="accordion">
<li><h3><a id="1"></a></h3></li>
<li><h3><a id="2"></a></h3></li>
<li><h3><a id="3"></a></h3></li>
</ul>
和JavaScript
<script type="text/javascript">
$(document).ready(function(){
$('#accordion li h3').click(function(){
//I want to alert the id attribute of a, but i don't know why
//I tried $(this+'a') or $('#accordion li h3:selected a') but it failed.
});
});
</script>
如果您有螢火蟲或另一種JavaScript錯誤控制檯(像Safari中的開發人員),請嘗試使用console.log而不是alert。記錄東西到控制檯需要少點擊:) – mikl 2009-06-08 09:07:37