0

I have a function like this... I am trying to insert a class name using a variable gotValue. How do I pass it in jQuery? I have tried that in if clause, but it did not work.

function fullData(gotValue)
{
    alert(gotValue);
    var count = gotvalue.substring(9);
    if($('.'+gotValue+'').is(':checked'))
    {
        alert('working');
    }
}
2
  • What is the value of variable gotValue you pass through the function? Commented Jul 30, 2010 at 10:13
  • @sAc - value like 'redtext' .. its just a class name Commented Jul 30, 2010 at 10:15

2 Answers 2

6

Javascript variables are case-sensitive; so:

gotValue != gotvalue
Sign up to request clarification or add additional context in comments.

1 Comment

+1 - He's throwing a syntax error on the var count line currently.
0

It's not that clear what you're trying to do but I think what you want is

$('.'+gotValue+":checked")

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.