gpt4 book ai didi

javascript - 从具有相同类的多个输入标签中获取 html

转载 作者:行者123 更新时间:2023-11-28 08:07:01 24 4
gpt4 key购买 nike

这是我到目前为止的代码...

function doAlertings()
{
var inputlabels = $('.inputLabel').each(function(i, obj) {

});
alert(inputlabels);
}

这将依次提醒我的所有 12 个输入标签,但它们都是空白的。但是当我使用...

var inputlabels = $('.inputLabel').html();
alert(inputlabels);

这只会提醒第一个输入标签并在那里停止。有人知道如何从每个文件中获取 html 吗?

非常感谢您的帮助。

谢谢

最佳答案

使用$(this).text()获取each中每个元素的文本循环

$('.inputLabel').each(function(i, obj) {
alert($(this).html()); // console.log($(this).text());
});

关于javascript - 从具有相同类的多个输入标签中获取 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24696625/

24 4 0