0
$(".className").click(function(){
    var link =  $(this).find("a").attr('href');
    //output is '#myID'

    var findItems = $(link '.mydiv').length; 
    //WRONG
    var findItems = $(link + '.mydiv').length; 
    //WRONG

    console.log(findItems);
    // WRONG NUMBER

});

if someone could correct my syntax please? suppose to be like var findItems = $('#myID .mydiv').length; but #myID should be a variable

2
  • instead of commenting wrong, would you mind putting the exact error on firebug console along with the relevant html code? Commented Sep 25, 2013 at 4:02
  • there is no errors, but the length number is not what I am expecting, it is incorrect! Commented Sep 25, 2013 at 4:04

1 Answer 1

1

try this

var findItems = $(myID).find('.mydiv').length;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.