2011-05-06 119 views

回答

2

你應該這樣做:

$('p').eq(0).slideUp(); //The same for slideDown 

乾杯

+0

我可以做到這一點$( 'P')當量(1).slideUp(); ? – Sourav 2011-05-06 05:38:19

+0

thanx misam:=) – Sourav 2011-05-06 05:42:13

+0

@Sourav。是的,你可以使用任何你想要的索引。很高興爲您效勞 – 2011-05-06 08:32:02

1

$('selector')[0]語法訪問原始DOM元素由選擇器匹配。要調用像slideUp這樣的jQuery函數,您應該省略像這樣的數組訪問操作:$('p').slideUp();如果您只想專門操作第一段,請改爲使用$('p:first')

1
$("p:eq(0)").slideUp();// This will select first 'P' tag and slide it up. You can change the index as per your requirement. 

切換它使用

$("p:eq(0)").toggle(); 
+0

我知道'$('p')。eq(0)',但從來沒有關於'$(「p:eq(0)」)'+1 – Sourav 2011-05-06 05:49:40

+0

請參閱http://api.jquery.com/eq-selector /獲取更多細節 – Misam 2011-05-06 05:57:42