Hacker
Hacker

Reputation: 7906

escaping a variable in jquery

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');
    }
}

Upvotes: 0

Views: 309

Answers (2)

Ollie Edwards
Ollie Edwards

Reputation: 14779

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

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

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382909

Javascript variables are case-sensitive; so:

gotValue != gotvalue

Upvotes: 6

Related Questions