当前位置:网站首页>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
});
边栏推荐
- Use and click of multitypeadapter in recycleview
- Domain Driven Design and coding
- 中低速航空航天电子总线概述
- Jar package merging using Apache ant
- @mysql
- Hibernate learning 2 - lazy loading (delayed loading), dynamic SQL parameters, caching
- 技术分享| WVP+ZLMediaKit实现摄像头GB28181推流播放
- Analysis report on operation mode and future development of global and Chinese methyl cyclopentanoate industry from 2022 to 2028
- C WinForm maximizes occlusion of the taskbar and full screen display
- Go crawler framework -colly actual combat (I)
猜你喜欢

Use of JMeter easynmon

无需显示屏的VNC Viewer远程连接树莓派

Im instant messaging development application keeping alive process anti kill
Fuxin Kunpeng joins in, and dragon lizard community welcomes a new partner in format document technical service

Why are life science enterprises on the cloud in succession?

Virtual machine - network configuration

传输层 以字节为单位的滑动窗口技术

Dynamic effect of canvas lines

Unmanned driving: Some Thoughts on multi-sensor fusion

时间统一系统
随机推荐
What exactly is Nacos
Global and Chinese tetrahydrofurfuryl butyrate industry operation pattern and future prospect report 2022 ~ 2028
∞ symbol line animation canvasjs special effect
有趣的checkbox计数器
canvas线条的动态效果
On the difficulty of developing large im instant messaging system
Use of JMeter
After 5 years of software testing in didi and ByteDance, it's too real
Scrollview height cannot fill full screen
Canvas spiral style animation JS special effect
WordPress add photo album function [advanced custom fields Pro custom fields plug-in series tutorial]
Difficult and miscellaneous problems: A Study on the phenomenon of text fuzziness caused by transform
Apk slimming compression experience
Intensive reading of thinking about markdown
C program design topic 18-19 final exam exercise solutions (Part 2)
[Solved] Public key for mysql-community-xxx. rpm is not installed
无需显示屏的VNC Viewer远程连接树莓派
More pictures | explain the Nacos parameters in detail!
在滴滴和字节跳动干了 5年软件测试,太真实…
部门新来的00后真是卷王,工作没两年,跳槽到我们公司起薪18K都快接近我了