Re: [問題] jQuery $('#')與document.getElementbyId
※ 引述《valda (valda)》之銘言:
: 剛剛google了很久
: 都是這樣寫"jQuery選擇的包裝集返回的是jQuery對象",
: "document.getElementByID返回的却是DOM对象"
: 實在看不懂
: 自己測試一下
: <table id="tbCustmoerInfo" class="client-data">
: <thead>
: <tr>
: <th>
: First Name
: </th>
: <th>
: Last Name
: </th>
: <th>
: Phone NO.
: </th>
: <th>
: Address
: </th>
: </tr>
: </thead>
: <tbody>
: <tr>
: <td>
: XXX
: </td>
: <td>
: EEE
: </td>
: <td>
: 00000
: </td>
: <td>
: aaaaa
: </td>
: </tr>
: </tbody>
: </table>
: console.log($('#tbCustmoerInfo'));
: 結果:[<table id=?"tbCustmoerInfo" class=?"client-data">…</table>]
: console.log(document.getElementById("tbCustmoerInfo"));
: 結果:<table id=?"tbCustmoerInfo" class=?"client-data">…</table>
: 還是不懂
$('#tbCustomerInfo').get(0)返回的就是document.getElementById('tbCustomerInfo')
$物件回傳的是一個屬於jQuery屬性的集合 支援各種jQuery的方法
也可以從$內拿到原始dom的元素
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 208.79.252.146
討論串 (同標題文章)