javascript - 手写笔:将样式添加到在 javascript 中生成的 id

标签 javascript html css jquery-ui stylus

我有一个jquery datepicker widget我正在使用,我想覆盖与其 input 字段关联的 CSS。

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

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

我们正在使用手写笔,我希望能够设计任何具有以“dp”开头的 inputid 的样式——有没有简单的方法以这种方式选择 id 的方法?

最佳答案

使用 attribute selector为了这。一个例子是:

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

jsFiddle example

关于javascript - 手写笔:将样式添加到在 javascript 中生成的 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19514268/

相关文章:

css - 样式图像链接成为焦点

asp.net - 知道在 .net 中清理要在 Javascript 中使用的字符串的好方法吗?

javascript - 谷歌地图上显示灰色网格

javascript - 选择给定元素之前和之后的 div 内容

html - Angular 组件倾斜的背景

javascript - 如何将 HTML 文件的内容导入到 <div> 中而不像对象一样?

javascript - Svelte:将 noscroll 类名从组件添加到正文

php - 神秘的 "1"出现在加载内容的末尾

javascript - 将多维输入数组转换为 JSON

jquery - 更改范围 slider handle 颜色(单击时)