How to add the align attribute to this line of code (inline) - HTML, JavaScript, and jQuery

StackOverflow https://stackoverflow.com/questions/17709658

Pergunta

I am looking to insert the align attribute for centering column data. I have several lines that are similar in composition to this:

tdHtml = tdHtml + "<td style=\"width:42px;\">" + PriorityFormat($(this).attr("ows_Priority_x0020_Number")); + "</td>";

Is this doable?

Thanks!

Foi útil?

Solução 2

Vega and Sushanth have answered this question in the comments above. I used

"<td style=\"width:42px;text-align:center \">"

Outras dicas

Don't use inline css add class or target td by parent selector

Example:

tdHtml = tdHtml + "<td class='td-center'>" + PriorityFormat($(this).attr("ows_Priority_x0020_Number")); + "</td>";

CSS

.td-center {width:42px; text-align:center}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top