jQuery document operation - insertAfter() method

Example

Insert span element before each p element:

$("button").click(function(){
  $("<span>Hello world!</span>").insertBefore("p");
});

Try it yourself

Definition and usage

insertBefore() method inserts HTML tags or existing elements before the selected element.

Comment:If this method is used for existing elements, these elements will be removed from their current position and then added before the selected element.

Grammar

content).insertBefore(selector)
Parameta Kwamfuta
content

Dauka. Dade a kaiwa saman da ke kaiwa. Zane na wuri:

  • Expressin da ke a kaiwa
  • HTML da ke a kaiwa
selector Dauka. Dade a kaiwa saman da ke kaiwa a kowane saman.

More shirin

Wajin saman da ke a kaiwa
Kako wajin shirin insertAfter() hukun wajin wajin da ke a kowane saman kaiwa saman da ke kaiwa a saman da ke kaiwa a kowane saman.