【发布时间】:2019-05-26 16:37:01
【问题描述】:
HTML:
<div class="col answer">
some text
</div>
js:
$(".answer").text("Here we change the text" );
$(".answer").click(function(E) {
console.log(E).html();
});
控制台输出:未定义
【问题讨论】:
-
console.log返回undefined...你的意思是console.log($(this).html())吗? E指索引 -
console.log($(E.target).html())将记录 html。或console.log(E.target.innerHTML)
标签: javascript jquery html click innerhtml