Original address: http://jingyan.baidu.com/article/7f41ececf93b48593d095c25.html
including myself (in fact, I've only known this for two days), and many users of jquery are deeply puzzled by this problem. Why can't you set the HTML element's outerhtml directly in a variety of convenient ways to get properties and set properties like Dom?
outerHTML to get and set HTML elements in the native Dom everyone is familiar with:
Native Dom Get outerhtml
Alert (' native Dom gets outerhtml ');
Alert (document.getElementById (' lz66303 '). outerHTML);
Native DOM Settings outerhtml
Alert (' native DOM set outerhtml ');
document.getElementById (' lz66303 '). outerHTML = ' <textarea id= ' lz66303 ' >
Of course in jquery we can use the . Prop () method to get and set the HTML element of the outerhtml, on the Internet if the search jquery get outerhtml unexpectedly still someone write function, sad! --jquery the method of self-bringing, I do not know also think oneself write a function This method is what good solution.
When you see this article, go to more jquery users who are still using custom functions to get outerhtml-I don't share this experience!
It's really that simple:
Successful acquisition to
Alert (' Jquery.prop () get outerhtml ');
Alert ($ (' textarea '). Prop (' outerhtml '));
Successful setup, already in effect
Alert (' Jquery.prop () set outerhtml ');
$ (' textarea '). Prop (' outerhtml ', ' <input> ');
How to get the outerHTML property by using jquery's own method/function