Q:

how to add style to span like .attr('style', 'width:newWidth '); where newWidth is dynamic

I have a code like below 
var newWidth = Math.floor(width * .75) + 'px';
$(this).find("input:first").attr('style', 'width:newWidth ');

could you please correct me as what should be the right syntax as passing newWidth directly is not working also I have to do this via style only

A:

Use .css()
$(this).find("input:first").css('width', newWidth);

