jQuery.parseHTML() | jquery change html text
Description:ParsesastringintoanarrayofDOMnodes.jQuery.parseHTMLusesnativemethodstoconvertthestringtoasetofDOMnodes,whichcanthenbeinsertedintothedocument.Thesemethodsdorenderalltrailingorleadingtext(evenifthatsjustwhitespace).Topreventtrailing/leadingwhitespacefrombeingconvertedtotextnodesyoucanpasstheHTMLstringthroughjQuery.trim[1].Bydefault,thecontextisthecurrentdocumentifnotspecifiedorgivenasnullorundefined.IftheHTMLwastobeusedinanotherdocumentsuchasaniframe,thatframesdocumentcouldbeused.A...
Description: Parses a string into an array of DOM nodes.
jQuery.parseHTML uses native methods to convert the string to a set of DOM nodes, which can then be inserted into the document. These methods do render all trailing or leading text (even if thats just whitespace). To prevent trailing/leading whitespace from being converted to text nodes you can pass the HTML string through jQuery.trim[1].
By default, the context is the current document if not specified or given as null or undefined. If the HTML was to be used in another document such as an iframe, that frames document could be used.
As of 3.0 the default behavior is changed. If the context is not specified or given as null or undefined, a new document is used. This can potentially improve security because inline events will not execute when the HTML is parsed. Once the parsed HTML is injected into a document it does execute, but this gives tools a chance to traverse the created DOM and remove a...