测试两个元素是否相同 [英] Test if two elements are the same

查看:67
本文介绍了测试两个元素是否相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑这最初会起作用:

I would suspect this to work at first:

if ($('#element') == $('#element')) alert('hello');

但事实并非如此。如何测试元素是否相同?

But it does not. How does one test if elements are the same?

推荐答案

从jquery 1.6开始,您现在可以简单地执行:

As of jquery 1.6 you can now simply do:

$element1.is($element2)

这篇关于测试两个元素是否相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆