gpt4 book ai didi

javascript - 当值更改时更新与 <input> 元素关联的 DB 值

转载 作者:行者123 更新时间:2023-11-30 10:14:13 24 4
gpt4 key购买 nike

我试着做这样的东西 http://jsfiddle.net/4e756/

$(document).ready(function(){
$('input[type=text]').keyup(function(){
var c=0;
var a=$(this).attr('name'); //a is string
//if var a change..a=a(old)+a(new) and c++; than i will
//explode string and use it for ajax POST
});
});

每次var a更改 我想使用它的值来增加另一个变量。这将允许我保存每个 <input> 的名称哪些变化。

最佳答案

使 a 变量成为全局变量并添加到它。

$(document).ready(function(){

var a=''; // initialize it as global and an empty string
$('input[type=text]').click(function(){
var c=0;
a = a + $(this).attr('name'); //a is string
//if var a change..a=a(old)+a(new) and c++; than i will
//explode string and use it for ajax POST
});
});

关于javascript - 当值更改时更新与 &lt;input&gt; 元素关联的 DB 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24834286/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com