Gaurav_0093
Gaurav_0093

Reputation: 1030

How to add a width to td using its id in jquery

<td  id="test_1"></td>

This is my td element inside the table element and I want to add width to it using jquery I used

 $('#test_' + 1).attr('width','256px');

But it is not working not adding width to the element nor showing any error in console

please help

Upvotes: 0

Views: 30

Answers (1)

Rich&#225;rd Baldauf
Rich&#225;rd Baldauf

Reputation: 1118

The attr method is not designed for this usually I am doing this with .css("width", "256px") EDIT: I have noticed you have added the "px" string at the end, if you remove the px from the end the attr should work also.

Upvotes: 1

Related Questions