当前位置:网站首页>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
});
边栏推荐
- ∞ symbol line animation canvasjs special effect
- What is the difference between one way and two way ANOVA analysis, and how to use SPSS or prism for statistical analysis
- Why do more and more physical stores use VR panorama? What are the advantages?
- 在滴滴和字节跳动干了 5年软件测试,太真实…
- Human body transformation vs digital Avatar
- C program design topic 18-19 final exam exercise solutions (Part 2)
- Fast pace? high pressure? VR panoramic Inn brings you a comfortable life
- 从数字化过渡到智能制造
- DO280OpenShift访问控制--加密和ConfigMap
- 无人驾驶: 对多传感器融合的一些思考
猜你喜欢
@mysql

svg+js键盘控制路径

A small program written this week

Svg+js keyboard control path

时间统一系统

Use coordinatorlayout+appbarlayout+collapsingtoolbarlayout to create a collapsed status bar
How to use promise Race() and promise any() ?

微搭低代码中实现增删改查

不重要的token可以提前停止计算!英伟达提出自适应token的高效视觉Transformer网络A-ViT,提高模型的吞吐量!...

JMeter socket connection sends data
随机推荐
无需显示屏的VNC Viewer远程连接树莓派
After 5 years of software testing in didi and ByteDance, it's too real
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
JMeter socket connection sends data
Use and click of multitypeadapter in recycleview
Difficult and miscellaneous problems: A Study on the phenomenon of text fuzziness caused by transform
Hibernate learning 3 - custom SQL
What is the difference between one way and two way ANOVA analysis, and how to use SPSS or prism for statistical analysis
Collective example
How to use promise Race() and promise any() ?
I suddenly find that the request dependent package in NPM has been discarded. What should I do?
Analysis report on operation mode and future development of global and Chinese methyl cyclopentanoate industry from 2022 to 2028
离散数学及其应用 2018-2019学年春夏学期期末考试 习题详解
One way 和two way ANOVA分析的区别是啥,以及如何使用SPSS或者prism进行统计分析
What is test development? Can you find a job at this stage?
MySQL log management
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
Design scheme of authority management of fusion model
Is it so difficult to calculate the REM size of the web page according to the design draft?
[distributed system design profile (2)] kV raft