jQuery प्रीपेन्ड करने के लिए () विधि
❮ jQuery के एचटीएमएल/सीएसएस तरीके
उदाहरण
प्रत्येक <p> तत्व की शुरुआत में एक <span> तत्व डालें:
$("button").click(function(){
$("<span>Hello World!</span>").prependTo("p");
});
परिभाषा और उपयोग
PrependTo () विधि चयनित तत्वों की शुरुआत में HTML तत्वों को सम्मिलित करती है।
युक्ति: चयनित तत्वों के अंत में HTML तत्व सम्मिलित करने के लिए, appendTo () विधि का उपयोग करें।
वाक्य - विन्यास
$(content).prependTo(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 at the beginning of the selected elements. |
selector | Required. Specifies on which elements to prepend the content to |
इसे स्वयं आज़माएं - उदाहरण
प्रत्येक चयनित तत्व की शुरुआत में एक मौजूदा तत्व सम्मिलित करने के लिए prependTo () विधि का उपयोग कैसे करें।
❮ jQuery के एचटीएमएल/सीएसएस तरीके