In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to use map in jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
In jquery, the use of map () is to use a specified function to handle each element or attribute of an object in an array, and to encapsulate the result of processing as a new array return, with the syntax of "$.map (objects or arrays to be processed, specified handlers)".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
What is the use of map in jquery
It is generally used to perform function processing for each element obtained.
The $.map () function is used to process each element in the array (or each attribute of the object) using the specified function and to encapsulate the result as a new array return.
The syntax is:
$.map (object, callback)
The array or object that needs to be processed specified by the object Array/Object type.
The handler specified by the callback Function type.
Examples are as follows:
123 div {color:blue;} p {color:green; margin:0;} span {color:red;}
$(function () {var arr = ["a", "b", "c", "d", "e"]; $("div") .text (arr.join (",")); arr = $.map (arr, function (n, I) {return (n.toUpperCase () + I);}); $("p") .text (arr.join (",")) Arr = $.map (arr, function (a) {return a + a;}); $("span") .text (arr.join (","));})
Output result:
This is the end of the content of "how to use map in jquery". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.