1👍
item.before($("li", result));
Should be
item.before($("li", $(result)));
Or, maybe
item.before($("li"), result));
Depends on what are you trying to achieve and your HTML structure.
The source of error is that second parameter to $
should be a DOM context or JQuery element to use as an element search tree top (i.e. only descendants are searched). With your code, you are trying to find li
s under the htmlString
, which is obviously an error. So, most likely it’s just a missing or misplaced )
.
You should stick with first if you are trying to find li
s inside the returned string. Use second if you are about to insert the returned html before li
s.
👤J0HN
Source:stackexchange.com