How to add style to selector via jquery.?
You were almost there. You have to give the parameter name and value seperately: $('a').css("background-color","red");
You could add it to the style
attribute:
$('a').attr('style', htmlattri);
But I would use .css()
:
$('a').css('background-color', 'red');
Or better yet, do it with a stylesheet and just use .addClass()
.