JQuery iterates through the child elements + each function jumps out + extracts the numbers in the string

Source: Internet
Author: User

Recently the head confused like a group of paste, has been wrong.

The HTML code, for example, now wants to implement a feature that is based on an AJAX request and gets a specific button to update its style. Because the button is more, each button is set ID, there is no meaning, want to through jquery's Traversal + descendants implementation

Core code:

$ ("#contentDiv"). Children (). each (function() {Console.log ($ ( This). Children (). Last (). text (). Match (/\d+/) + "); Console.log ($ ( This). Children (). Last (). text ()); Console.log (info.            MSG); Console.log (info. Msg.match (/\d+/) + "); if($( This). Children (). Last (). text (). Match (/\d+/) + "= = info. Msg.match (/\d+/) + ") {                //Set Style                                return false; }        });

A few notes: (1) Each function of the jump, directly with break,continue, the hint is wrong. Use return to implement Continue,return false implementation break, reference: http://hyj1254.iteye.com/blog/497079

(2) The extraction of numbers in a string, using this regular expression:

Match (/\d+/) + '

JQuery iterates through the child elements + each function jumps out + extracts the numbers in the string

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.