简体   繁体   中英

Strange behavior with JQuery and Vuejs

I am using VueJS and jQuery with following dependencies. Can someone explain why the result is true in one place and false in other?

在此处输入图像描述

"dependencies": {
    "bootstrap": "^4.3.1",
    "bootstrap-vue": "^2.1.0",
    "core-js": "^3.3.2",
    "jquery": "^3.4.1",
    "vue": "^2.6.10"
 }

You can not compare if two jQuery objects are the same. But you can compare DOM objects.

To know more about the comparison of jQuery object you can have a look at this Stackoverflow Answers

This link also has an explanation

The dollar '$' in the console isn't jQuery. It's unable to access jQuery because it's not in the global scope. Besides, when comparing two jQuery objects, they always return false because they are not equal. In the console, because two objects aren't jQuery objects, they are both null instead, thus they are equal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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