Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道使用 .css() 使用 jquery 将 css 应用于 DOM,我想知道是否有任何 .attr 或 .att 方法,以便我可以使用 jquery 将对齐属性分配给表头。如果是,请告诉我代码。
<table> <th > </th> <th > </th> <th > </th> </table>
这是一个这样的示例代码$(element).attr("nameAttr",valueAttr);,您可以将任何属性添加到任何 html 元素
$(element).attr("nameAttr",valueAttr);
我不确定这是否是您要查找的内容,但您可以像这样添加属性
$("th").attr("align", "left");
艰难的你应该尝试CSS设置对齐方式,但 jQuery 仍然提供attr如下功能:
CSS
attr
$("th").attr("align","left");