+ 3
$(function() { var txt = $("<p></p>").text("Hi"); $("#demo").after(txt); });
i want "Hi" to appear 2 times , but by repeating the same query twice i am not getting the result, so should i declare a new variable to store the same value or is there any other method? Also what should i do if i want to create 2 'p' tags with different id , using jquery
1 Answer
+ 2
I wouldn't repeat the query, I would call the function twice from the applicable section in the HTML.
The answer to the second question sort of depends on what the purpose of doing that would be and what you want the id's to end up looking like (what you're planning on naming them). Maybe there would be a better choice.