Create an issue with jquery that does not exist in the HTML tag element

Source: Internet
Author: User

If you customize a label, such as <aaa></aaa>

Using jquery, such as var custom_element = $ (' <aaa class= ' ee ></aaa> ');

There is no problem building the object, but if you add elements such as custom_element.append (' <div>ok</div> ') to the object, an exception is thrown under IE8: "The method or property access is called unexpectedly." ”

If only $ (' <aaa></aaa ') is generated, it will not be an exception, but adding attributes such as class will cause problems.

There are two solutions: 1. Take the class out, use jquery to create only the elements, and then modify the properties of the custom tags, such as addclass and attr.

2. Use the $ (document.createelement (' AA ')) method to convert the native JS created object to a jquery object, and then modify the properties of the custom element using methods such as AddClass or attr.

3. Using IE9 or later browsers

Create an issue with jquery that does not exist in the HTML tag element

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.