jquery dynamically add value for Attribute Filters?
Question
I have Attribute Filter like this one $(’input[name="email"]‘);
I want to create a function with parameter, which would contain name of attribute..something like this:
function test(id_new){
var var_name = $("input[name='"+id_new+"']:checked").val();
alert(var_name);
}
but this code is not working, any solutions?
Solution
Which version of jQuery are you using? I'll assume 1.3.
Try removing the single quotes in the attribute selector:
function test(id_new){
var var_name = $("input[name="+id_new+"]:checked").val();
alert(var_name);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow