简体   繁体   English

需要帮助使用jquery从浏览器控制台选择标签

[英]Need help selecting tags from browser console using jquery

I am getting an error trying to get each tag with a certain class and only the innerHTML of the tag. 我在尝试获取具有特定类的每个标签以及仅包含标签的innerHTML时遇到错误。 I am trying to 我在尝试着

$(".acol").innerHTML.each(function(i) {
  console.log($(this));
});

but getting errors as it is passing to .each . 但是在passing to .each Can anyone help? 有人可以帮忙吗? I think it is fairly simple. 我认为这很简单。

thanks! 谢谢!

.innerhtml returns string not an object so you got the error and .each needs array or object . .innerhtml 返回字符串而不是对象,所以您得到了错误, .each 需要数组或对象 However, you can change your code to the below code: 但是,您可以将代码更改为以下代码:

$(".acol").each(function(i) {
  console.log($(this).html());
});

Try this, 尝试这个,

$.each($(".labelCol"),function(key,val){
   var innerHTML = $(val).html();
});

Try this 尝试这个

$(".acol").each(function(i) {
  console.log($(this).html()); 
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM