Creating a jQuery object from a big HTML-string
Update: From jQuery 1.8, we can use $.parseHTML, which will parse the HTML string to an array of DOM nodes. eg: var dom_nodes = $($.parseHTML(‘<div><input type=”text” value=”val” /></div>’)); alert( dom_nodes.find(‘input’).val() ); DEMO var string = ‘<div><input type=”text” value=”val” /></div>’; $(‘<div/>’).html(string).contents(); DEMO What’s happening in this code: $(‘<div/>’) is a fake <div> that does not exist … Read more