Greetings stackoverflow,
Ive got html code saved as a js variable named 'test'.
I then am attempting to target a specific (the 5th) li item and append the HTML in a line under that with :
var target = $("ul[class='productWrapper']>li:nth-child(5)");
$(test).insertAfter($(target));
I believe I have a syntax issue with how i am trying to target that LI element and im not sure if insertAfter is the proper method to use for this task.
All of your thoughts are welcome!
I think whatever you have there is about right, @JoeG. I've taken the liberty of putting a bit more context around it and it seems to work just fine. I changed your syntax a tiny bit, but not the main line in question. There are two elements only to make it clear that the .insertAfter() is hitting the right one, and only that one.
Here's the HTMl with script at the bottom.
After the page fully loads and the script is complete, this is how the page looks, which I believe is what you had in mind.