Assign a value to a variable in jquery

advertisements

How do i assign a value to a variable in Jquery

    {var c2;
    $(c2).val("standard_desc");
    alert (c2);
    $('#ANDCriteria2').val(c2); 

    }

I am trying to set variable's value, it will be static. In next line i am trying to set dropdown's selected value using same variable. I know i can just type

$('#ANDCriteria2').val("standard_desc");

But i have different requirement, please guide.


i have no idea why you have { there in your question.. are you missing something.. anyways assigning value to a variable is super simple.. use = operator

var c2 = "standard_desc";
 alert(c2);
 $('#ANDCriteria2').val(c2);