天天看點

jQuery Recipies - 使用map來過濾對應的元素集

$("tr:gt(0)") selects all the HTML elements with the tag name "tr" except for the first record and returns the

jQuery object.

.map() iterates through each element from the set of selected elements and processes them in the function.

return $(this).children().first().text() returns the text content of the first child element (td) of each

selected "tr" element, which is the employee name.

A new jQuery object (jqObj) is created that contains elements as a result of the return value of the function.

jqObj.get() gets all the HTML elements from the jQuery object as an array.

.join(", ") joins all elements from the array, delimits them with commas (,) and returns a string that contains

a comma-delimited list of all the employees’ names.

繼續閱讀