I am going to get a element from a html-string with jQuery, but I always get an undefined in my console. My String is:
asd
First, use jQuery.parseHTML to parse the HTML into an array of elements; then you’ll be able to convert it to a jQuery collection and use filter to restrict the collection to elements matching a selector.
var html =
'asd ' +
'fgh ' +
'jkl ';
var text = $($.parseHTML(html)).filter('.test').text();
console.log(text);