Blog (string)

@fredwu 14 years ago | 1 min read | no comments
When you are getting an HTML string from an external source (e.g. from an AJAX get result) and you want to rip out a certain part of the HTML source, you need to make sure that the ‘certain part’ is not at the top level of the HTML source. For example, we have the following HTML string: Hello World If we want to get the first paragraph element by using: // data is the HTML source $('span#first', data) The above code won’t work, because the p tags are at the top level. Instead...