简体   繁体   中英

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

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!

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}

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM