Stylus:为在 JavaScript 中生成的 ID 添加样式

stylus: add styling to an id that is generated in javascript

本文关键字:ID 添加 样式 为在 JavaScript Stylus      更新时间:2023-09-26

我有一个正在使用的jquery日期选择器小部件,我想覆盖与其input字段关联的CSS。

不幸的是,看起来该字段的id是在页面加载时动态生成的:

<input type="text" id="dp1382434269539" style="position: absolute; top: 372.9375px; width: 0px; left: 579.8125px;">

我们正在使用手写笔,我希望能够设置任何以"dp"开头的inputid - 有没有一种简单的方法可以通过这种方式选择id

为此

使用属性选择器。一个例子是:

input[id^="dp"] {
    /* your styling */
}

js小提琴示例