1 - 我寫的代碼來獲取所有「要訪問」元素在此代碼,如「一些數據」沒有其他的元素,只想元素,其DIV類bestMFdtl2。如何在HTML代碼中訪問元素
2-如果我想根據選擇如何在此代碼中使用某些特定元素如何做到這一點,我使用html jerico parser.Please幫助我和那些有問題的閱讀代碼我很抱歉,但你是程序員我以爲你喜歡這樣。
3-如何從標籤獲取href鏈接。
<div class='bestMFdtl2 '>
<div class='tBrd btBrd tbg'>
<div class='FL eqTle2 wd_182 rtBrd PL10 PR10'><a href='' class='bl_11'><strong></strong></a></div>
<div class='FL eqTle wd_65 rtBrd PL5 PR5' align='center'><strong>some data</strong></div>
<div class='FL eqTle wd_83 rtBrd' align='center'>
<div class='btBrd'><strong>some data</strong> <span style='font-size:8px;'>some data</span></div>
<div class='PT3'>some data</div>
</div>
<div class='FL eqTle wd_46 rtBrd btBrd' align='center'><strong>some data</strong></div>
<div class='FL eqTle rtBrd'>
<div align='center' class='btBrd'><strong>some data</strong></div>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='center' width='56' height='20' class='rtBrd'><strong>some data <sup>some data</sup></strong></td>
<td align='center' width='56' class='rtBrd'><strong>some data <sup> </sup></strong></td>
<td align='center' width='56' class='rtBrd'><strong>some data <sup> </sup></strong></td>
<td align='center' width='56' class='rtBrd'><strong>some data<sup> </sup></strong></td>
<td align='center' width='56' class='rtBrd'><strong>some data<sup>*</sup></strong></td>
<td align='center' width='56'><strong>some data <sup>*</sup></strong></td>
</tr>
</table>
</div>
<div class='FL btBrd' style='width:43px;'></div>
<div class='CL'></div>
</div>
<div class='equityN2'>
<table cellspacing='0' cellpadding='0' style='margin-top:5px;'><tr>
<td width='185'><div align='left'><a class='b-12' title='BNP Paribas Equity Fund (G)' href=''>Want to access</a> </div></td>
<td width='70' nowrap=''><a href='' class='dgrey_12' target='_blank'>Rank 1</a><br><a href='/mf/crisil_methodology/' target='_blank'><span class='star'></span><span class='star'></span><span class='star'></span><span class='star'></span><span class='star'></span></a></td>
<td width='70' style='text-align:right;'>127.22</td>
<td width='40' style='text-align:right;'>42.03</td>
<td class='#000000' width='48' style='text-align:right;'>--</td>
<td class='grn' width='48' style='text-align:right;'>3.0</td>
<td class='grn' width='48' style='text-align:right;'>10.3</td>
<td class='grn' width='48' style='text-align:right;'>6.6</td>
<td class='grn' width='50' style='text-align:right;'>18.9</td>
<td class='grn' width='50' style='text-align:right;'>5.6</td>
<td><A href='want to access' title='Download Form' target='_new' class='mfToolt'><img src='' alt=''></A></td>
</tr><tr>
<td width='185'><div align='left'><a class='b-12' title='' href='/'>want to access</a> </div></td>
<td width='70' nowrap=''><a href='' class='dgrey_12' target='_blank'>Rank 1</a><br><a href='/mf/crisil_methodology/' target='_blank'><span class='star'></span><span class='star'></span><span class='star'></span><span class='star'></span><span class='star'></span></a></td>
<td width='70' style='text-align:right;'>105.26</td>
<td width='40' style='text-align:right;'>12.37</td>
<td class='grn' width='48' style='text-align:right;'>0.7</td>
<td class='grn' width='48' style='text-align:right;'>3.1</td>
<td class='grn' width='48' style='text-align:right;'>8.8</td>
<td class='grn' width='48' style='text-align:right;'>3.6</td>
<td class='grn' width='50' style='text-align:right;'>16.1</td>
<td class='grn' width='50' style='text-align:right;'>5.8</td>
<td><A href='want to access' title='Download Form' target='_new' class='mfToolt'><img src='' alt=''></A></td>
</tr>
解決了你的問題 - 但我沒有經歷這個地獄的代碼。請修復您的代碼樣式,以便我們可以看到問題所在。我不需要完整的代碼 - 一個簡短的例子將幫助:) –
我不完全確定你在問什麼,但看看[document.getElementsByClassName](https://developer.mozilla.org/ en-US/docs/Web/API/document.getElementsByClassName)並查看是否有助於解決問題 – DBS
您似乎在詢問有關訪問多種不同的內容的問題。最簡單的方法是將ID添加到元素中,然後添加「document.getElementById」。如果這是不可能的,也許嘗試獲取父元素並從中拉出href列表。 – DBS