jQuery eq () विधि
उदाहरण
दूसरा <p> तत्व चुनें (इंडेक्स नंबर 1):
$("p").eq(1).css("background-color", "yellow");
परिभाषा और उपयोग
eq() विधि चयनित तत्वों की एक विशिष्ट अनुक्रमणिका संख्या के साथ एक तत्व देता है।
सूचकांक संख्या 0 से शुरू होती है, इसलिए पहले तत्व में सूचकांक संख्या 0 (1 नहीं) होगी।
वाक्य - विन्यास
$(selector).eq(index)
Parameter | Description |
---|---|
index | Required. Specifies the index of the element. Can either be a positive or negative number. Note: Using a negative number will start the index count from the end of the selected elements, instead of the beginning. |
इसे स्वयं आज़माएं - उदाहरण
का उपयोग करना चयनित तत्वों के अंत से दूसरा <p> तत्व वापस करने के लिए ऋणात्मक संख्या का उपयोग करना।