gpt4 book ai didi

javascript - 将 javascript 函数转换为 jQuery

转载 作者:行者123 更新时间:2023-11-30 18:38:27 25 4
gpt4 key购买 nike

如何将这个选择的 javascript 转换为 jQuery?我需要选择按钮类而不是 ID,我知道最简单的方法是 jQuery。

var playButton1 = document.getElementById("playButton1");

playButton1.onclick = function() {
var ta = document.getElementById("playButton1");

document['player'].receiveText1(ta.value);

ta.value = ""
};

最佳答案

尝试以下操作。您没有指定新类名,所以我假设它是“playButton”。

$(document).ready(function() {
$('.playButton').click(function() {
document['player'].receiveText1(this.value);
this.value = "";
});
});

关于javascript - 将 javascript 函数转换为 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7536147/

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