I am currently working on a project where most of the code has been written by someone else . I was supposed to do some slight modifications in the existing script to incorporate changes in a new file. I came across a situation where it was very confusing . The scenario is as cited below:
I have an element named as complextabs
and it is being used for almost all the pages, except for the one which is being created newly. The situation is there is a code snippet that is written as $('.complextabs').hasClass('.hide')
. this incredibly returns the same as when the element complextabs
is not even present in the page. Can someone please throw some light on this
And yeah, I am working on Backbone.js
. Has this got something to do with the use of Backbone.js
Any suggestion and advice is highly appreciated
Nope, that has nothing to do with the use of Backbone.
Consider the following:
This will return false, and it should return false because
$('.asdasda')
does not return any results. Just running that will yield a JQuery wrapper over an empty list and since there are no elements then obviously there's nothing in there with the css classhide
.If you want to check that there is an element with both the
complextabs
and thehide
class then use$('.complextabs.hide').length
.