当前位置:网站首页>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
});
边栏推荐
- 【面试题】什么是事务,什么是脏读、不可重复读、幻读,以及MySQL的几种事务隔离级别的应对方法
- C程序设计专题 15-16年期末考试习题解答(上)
- 离散数学及其应用 2018-2019学年春夏学期期末考试 习题详解
- linux 系统redis常用命令
- Color gradient gradient color collection
- 从数字化过渡到智能制造
- OTT营销之风正盛,商家到底该怎么投?
- Signal integrity (SI) power integrity (PI) learning notes (I) introduction to signal integrity analysis
- DO280OpenShift访问控制--加密和ConfigMap
- Signal integrity (SI) power integrity (PI) learning notes (XXV) differential pair and differential impedance (V)
猜你喜欢

OTT营销之风正盛,商家到底该怎么投?

Collective example

JMeter socket connection sends data

What are the advantages of VR panoramic production? Why is it favored?

∞ symbol line animation canvasjs special effect

Meta & Berkeley proposed a universal multi-scale visual transformer based on pooled self attention mechanism. The classification accuracy in Imagenet reached 88.8%! Open source

融合模型权限管理设计方案
[distributed system design profile (2)] kV raft

svg+js键盘控制路径

Adding, deleting, modifying and checking in low build code
随机推荐
Overview of medium and low speed aerospace electronic bus
Difficult and miscellaneous problems: A Study on the phenomenon of text fuzziness caused by transform
Tape SVG animation JS effect
One way 和two way ANOVA分析的区别是啥,以及如何使用SPSS或者prism进行统计分析
OTT营销之风正盛,商家到底该怎么投?
Common redis commands in Linux system
im即时通讯开发应用保活之进程防杀
干接点和湿接点
Color gradient gradient color collection
Creative SVG ring clock JS effect
VNC viewer remote connection raspberry pie without display
Time unified system
Tongji and Ali won the CVPR best student thesis, lifeifei won the Huang xutao award, and nearly 6000 people attended the offline conference
Use of JMeter easynmon
Fast pace? high pressure? VR panoramic Inn brings you a comfortable life
Why are life science enterprises on the cloud in succession?
Global and Chinese tetrahydrofurfuryl butyrate industry operation pattern and future prospect report 2022 ~ 2028
Hibernate learning 3 - custom SQL
Android SQLite database
Is it so difficult to calculate the REM size of the web page according to the design draft?