作者screwup (心不在)
看板Ajax
标题Re: [问题] jQuery $('#')与document.getElementbyId
时间Tue Aug 21 18:21:25 2012
※ 引述《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