我喜歡我的html代碼:如何使用jQuery獲取第n個孩子的屬性?
<ul id="abc">
<li><a href="http://koolfinance.blogspot.com/2011/06/laxmi-bank.html">Laxmi Bank</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/nepal-development-bank.html">Nepal
Development Bank</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/clean-energy-development-
bank.html">Clean Energy Development Bank</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/gorkha-development-bank.html">Gorkha
Development Bank</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/bank-of-kathmandu.html">Bank of
Kathmandu</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/nic-bank.html">NIC Bank</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/bank-of-asia-nepal-limited.html">Bank
of Asia Nepal Limited</a></li>
<li><a href="http://koolfinance.blogspot.com/2011/06/nepal-sbi-bank-ltd.html">Nepal SBI
Bank Ltd.</a></li>
</ul>
我需要找到href
值或具體指標的標籤的目標頁面。例如: - 如果指數是1,它應該返回:http://koolfinance.blogspot.com/2011/06/nepal-development-bank.html
我想:
$targetLink = $('#abc a:nth-child(' + myIndex + ')').attr('href');
但其返回不確定。
以及我發現你得到正確答案第一... thnx ... – KoolKabin 2011-06-16 19:14:14