gpt4 book ai didi

jquery $(this) 到底是如何存储的?

转载 作者:行者123 更新时间:2023-12-01 06:01:41 24 4
gpt4 key购买 nike

参见this基本示例:

<div id="cont">
<input type=button value='button'>
</div>
<input type=button value='button'>

脚本:

$('input').click(function(){
console.log($(this));
console.log($('#cont').has($(this)));
console.log($('#cont').has($(this)).length);
console.log("---");
});​

在两个按钮单击中,根据 console.log 的 $(this) 值是相同的:

[<input type=​"button" value=​"button">​] 

为什么他们给出的结果仍然不同?

换句话说,当我控制台记录 $(this) 时,某些信息并未表示出来。该信息可能指向元素的唯一ID。但它是什么?它存储在哪里?为什么日志中没有显示?

最佳答案

只是看起来相同,因为按钮具有相同的标记。

Edited example

关于jquery $(this) 到底是如何存储的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10897013/

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