当前位置:网站首页>JS dynamically generates variable names and assigns values
JS dynamically generates variable names and assigns values
2022-06-25 00:21:00 【Mr, Guo】
JS Dynamically generate variable names and assign values
let vars = {
}; // Batch definition attribute name
for(var i = 0;i < 10; i++){
let attrName = 'my-'+i; // Dynamically define variable names
vars[attrName] = 'value-'+i; // Dynamic assignment
}
console.log(vars);
## jquery obtain table Although there are rows of data and dynamic attribute names and values are generated
let tableArr = []; // Save all data
$("#funTable tr:not(:first)").each(function(){
// Traverse all rows except the header row
let vars={
}; // Store row data
$("input:not(:button),select",this).each(function(){
// Traversing in-line input select Value Exclude button
let attrName = this.name; // Dynamically define the attribute name
vars[attrName] = $(this).val(); // Dynamically assign values to attribute names
});
tableArr.push(vars); // Row data format
});
边栏推荐
- Hibernate learning 2 - lazy loading (delayed loading), dynamic SQL parameters, caching
- How can I persuade leaders to use DDD to construct the liver project?
- Go crawler framework -colly actual combat (4) -- Zhihu answer crawl (2) -- visual word cloud
- 水库大坝安全监测
- Zed acquisition
- 不重要的token可以提前停止计算!英伟达提出自适应token的高效视觉Transformer网络A-ViT,提高模型的吞吐量!...
- Domain Driven Design and coding
- C程序设计专题 15-16年期末考试习题解答(上)
- 在滴滴和字节跳动干了 5年软件测试,太真实…
- What are the advantages of VR panoramic production? Why is it favored?
猜你喜欢

Unimportant tokens can be stopped in advance! NVIDIA proposes an efficient visual transformer network a-vit with adaptive token to improve the throughput of the model

What exactly is Nacos

技术分享| WVP+ZLMediaKit实现摄像头GB28181推流播放

svg+js键盘控制路径

Ten commandments of self-learning in machine learning

Human body transformation vs digital Avatar
5-minute NLP: summary of 3 pre training libraries for rapid realization of NER

JPA learning 2 - core annotation, annotation addition, deletion, modification and query, list query result return type, one to many, many to one, many to many

2019 summary and 2020 outlook

Encryption and encoding resolution
随机推荐
Ten commandments of self-learning in machine learning
DO280OpenShift访问控制--加密和ConfigMap
Do280openshift access control -- encryption and configmap
融合模型权限管理设计方案
WordPress add photo album function [advanced custom fields Pro custom fields plug-in series tutorial]
linux 系统redis常用命令
5-minute NLP: summary of 3 pre training libraries for rapid realization of NER
Zed acquisition
The new employee of the Department after 00 is really a champion. He has worked for less than two years. The starting salary of 18K is close to me when he changes to our company
Time unified system
【排行榜】Carla leaderboard 排行榜 运行与参与手把手教学
怎么把wps表格里某一列有重复项的整行删掉
信号完整性(SI)电源完整性(PI)学习笔记(二十五)差分对与差分阻抗(五)
离散数学及其应用 2018-2019学年春夏学期期末考试 习题详解
What is the difference between one way and two way ANOVA analysis, and how to use SPSS or prism for statistical analysis
Investment analysis and prospect forecast report of global and Chinese propargyl chloride industry from 2022 to 2028
[distributed system design profile (2)] kV raft
Hibernate learning 2 - lazy loading (delayed loading), dynamic SQL parameters, caching
Collective example
The drawableleft of the custom textview in kotlin is displayed in the center together with the text