How to insert an object before all paragraphs using jQuery ?
Approach: You can insert a jQuery object before all paragraphs by using the method called .before().
before(): This method is used to insert content specified by the parameter, before each element in the set of matched elements. It can accept any number of additional argument like – .prepend() and .after().
isnertBefore(): It is similar to the above function but the content precedes the method and is inserted before the target, which in turn is passed as the .insertBefore() method’s argument.
Before click: In the body element, we have initially 3 different paragraphs named – PHP tutorial, Python Tutorial, and Java Tutorial.
After click: After clicking the button, You can now notice that GeeksForGeeks.com is inserted before each paragraph.