我有這個測試頁面:使用方法只有一個單一的元素
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<h1>test1</h1>
<h1>test2</h1>
<h1>test3</h1>
我可以隱藏使用$('h1').hide()
的所有元素,但什麼原因,我不僅可以隱藏的第二個元素,使用$('h1')[1].hide()
?我怎樣才能做到這一點?
使用$('h1')[1].hide()
我收到以下錯誤信息:
Uncaught TypeError: $(...)[1].hide is not a function
at <anonymous>:2:12
at Object.InjectedScript._evaluateOn (<anonymous>:895:140)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
at Object.InjectedScript.evaluate (<anonymous>:694:21)
$( 'H1'),EQ(1).hide() – Dreamweaver