How to get the outerHTML property by using jquery's own method/function

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.