Write two or more elements style in single line in JQuery, where id of element created concatinating text by json object.value
checkSucess = function(first,last,value) {
// Jquery ajax with url,params and response
doPost('sucess.php',
'first=' + first +
'&last=' + last,
function(response) {
var obj = $.parseJSON(response);
$('#button'+obj.a,'#button'+obj.b,'#button'+obj.c).css({'text-decoration':'blink','color':'#4ECFBD'});
}
);
}
Here
$('#button'+obj.a).css({'text-decoration':'blink','color':'Magenta','font-weight':'bold'});
$('#button'+obj.b).css({'text-decoration':'blink','color':'Magenta','font-weight':'bold'});
$('#button'+obj.c).css({'text-decoration':'blink','color':'Magenta','font-weight':'bold'});
works correct ,
but
$('#button'+obj.a,'#button'+obj.b,'#button'+obj.c).css({'text-decoration':'blink','color':'#4ECFBD'});
not works why?
You have to merge the selectors in a string, in this way:
Alternatively, you can use the
.add()method to merge selectors: