jQuery डालने से पहले () विधि
❮ jQuery के एचटीएमएल/सीएसएस तरीके
उदाहरण
प्रत्येक <p> तत्व से पहले एक <span> तत्व डालें:
$("button").click(function(){
$("<span>Hello world!</span>").insertBefore("p");
});
परिभाषा और उपयोग
सम्मिलित करें () विधि चयनित तत्वों से पहले HTML तत्वों को सम्मिलित करती है।
युक्ति: चयनित तत्वों के बाद HTML तत्वों को सम्मिलित करने के लिए, सम्मिलित करें () विधि का उपयोग करें।
वाक्य - विन्यास
$(content).insertBefore(selector)
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (must contain HTML tags). Note: If content is an existing element, it will be moved from its current position, and inserted before the selected elements. |
selector | Required. Specifies where to insert the content |
इसे स्वयं आज़माएं - उदाहरण
प्रत्येक चयनित तत्व से पहले मौजूदा तत्व सम्मिलित करने के लिए insertBefore() विधि का उपयोग कैसे करें।
❮ jQuery के एचटीएमएल/सीएसएस तरीके