locked
variable + string selector RRS feed

  • Question

  • User-1826049516 posted

    Hi,

    I'm setting favHead early on as I reference it in many places. This doesn't work:

    $( favHead + " span[data-label='count']" ).children().each( function() {
    	// do stuff
    }

    This is the equivalent of:

    $( ".header[data-content='FAV'] span[data-label='count']" ).children().each( function() {
    	// do stuff
    }

    I'm setting favHead like so:

    var favHead = $( ".header[data-content='FAV']" );

    Everywhere I read is saying this should work. What am I doing wrong?

    Thanks.

    Saturday, February 17, 2018 10:55 AM

Answers

  • User-1826049516 posted

    Worked it out:

    favHead.find( "span[data-label='count']" ).children().each( function() {
    	//do stuff
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 17, 2018 11:05 AM