Jquery's clone method is applied to textarea and select bug fixes _ jquery

Source: Internet
Author: User
Textarea and select values will be discarded during clone, and val will be assigned again during clone. If you know this, you will add a ticket to the test and find that, the clone method of textarea and select jquery is faulty. The clone method of textarea and select values will be lost. It is found that this is a bug of jquery and you can check the Code if you cannot, relatively simple. In the clone operation, the val value is assigned again. If you know this, you can simply write it yourself.

The clone page you want to use is OK.

Jquery. fix. clone. js

(Function (original) {jQuery. fn. clone = function () {var result = original. apply (this, arguments), my_textareas = this. find ('textarea '). add (this. filter ('textarea '), result_textareas = result. find ('textarea '). add (result. filter ('textarea '), my_selects = this. find ('select '). add (this. filter ('select'), result_selects = result. find ('select '). add (result. filter ('select'); for (var I = 0, l = my_textareas.length; I <l; ++ I) $ (result_textareas [I]). val ($ (my_textareas [I]). val (); for (var I = 0, l = my_selects.length; I <l; ++ I) result_selects [I]. selectedIndex = my_selects [I]. selectedIndex; return result ;};} (jQuery. fn. clone );

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.