Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hasClass does not work as expected

See original GitHub issue

This is a (multiple allowed):

  • bug
  • feature-discussion (RFC)

I want to test if any (at least one) element in my list has the class .bingo. I have a 5 li-tags and 1 tag is associated with class .bingo:

var containBingo = $$('#mylist li').hasClass('bingo');

this will always return “false”, even one tag in my list is associated with class “.bingo”.

I have to do this to get “containBingo” to “true”

    $$('#app_menu li').each(function() {
        if ($$(this).hasClass('bingo')) {
            containBingo = true;

However, the f7 docs says this about hasClass():

Determine whether any of the matched elements are assigned the given class.

So according to the docs it must return true, because there is one element with class .bingo.

Is this a bug?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

virtual-vickycommented, Sep 13, 2016


I don’t think it’s a bug!! Though that totally depend upon your context of class “Bingo”…😁

On Tuesday, September 13, 2016, Zander wrote:

this will be the callback. use value

$$(‘#app_menu li’).each(function(index, value) { if ($$(value).hasClass(‘bingo’)) { console.log(‘BINGO’); containBingo = true; } });

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread .

lock[bot]commented, Jun 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery "hasClass()" not working? - Stack Overflow
I need the div on the bottom to hide when the word "click" is.. well.. clicked. It adds a class to the middle...
Read more >
hasClass not working for some reason... - jQuery Forum
Hi, I've been pulling my hair out trying to figure out what is wrong with my code here: // Add attributes to external...
Read more >
If element hasClass, is not working - Codecademy
Why is this not working:? **HTML** First item Second item Third item Fourth item **jQuery** $(document).ready(function(){ if( $("li").hasClass("active") ) ...
Read more >
hasClass returns false unexpectedly in v3 #1177 - GitHub
I've tried multiple combinations, like datePicker.getDOMNode().hasClass but these are not working either. Thanks in advance for help!
Read more >
How to use hasClass function in JQuery - Javascript - Tabnine
QUnit.test('should remove "collapsed" class from target when collapse is shown via manual invocation', ; assert.expect(1) ; var done = assert. ; var $target...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found