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