0

I know to apply css to DOM using jquery using .css() , I want to know is there any .attr or .att method so that I can assign align attribute to table header using jquery. If yes please show me the code.

<table>
<th >
</th>
<th >
</th>
<th >
</th>
</table>
1
  • there is no such th in my html. It is generated dynamically by ASP.Net engine. Actually its grid header. I am trying to apply the th{horiz-align:left } css in my css file but no use Commented Jul 4, 2012 at 5:28

3 Answers 3

1

Here is a sample code $(element).attr("nameAttr",valueAttr); like this you can add any attribute to any html element

Sign up to request clarification or add additional context in comments.

Comments

0

i am not sure if that what you are looking for but you can add atribute to th like this

$("th").attr("align", "left");

Comments

0

Tough you should try CSS to set alignment but still jQuery does provide with attr function like:

$("th").attr("align","left");

2 Comments

Is it enough to set alignment on page load??
If grid is there on page load then it will be okay otherwise you will need to set it after grid is rendered. Also make the selector more specific so that it actually gets the th element in the grid header. If you are not able to fix it please post html of rendered grid header.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.