views:

32

answers:

2

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');
    }
}
+6  A: 

Javascript variables are case-sensitive; so:

gotValue != gotvalue
Sarfraz
+1 - He's throwing a syntax error on the `var count` line currently.
Nick Craver
good catch! :) ...
Daniel Vassallo
thanks ..tht helped...
pradeep
@pradeep: You are welcome :)
Sarfraz
now mark it the answer heheh :)
jacobangel
A: 

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

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