Javascript jQuery datepicker样式天宽度并添加多个元素
我想:Javascript jQuery datepicker样式天宽度并添加多个元素,javascript,jquery,css,datepicker,jquery-ui-datepicker,Javascript,Jquery,Css,Datepicker,Jquery Ui Datepicker,我想: 在特定日期设置CSS宽度的样式(例如,内部有电源条) 在这些特定日期内添加多个元素 这就是我试图为演示(硬编码)设计它们的方式,但我需要它是动态的: 函数特殊日期(日期){ 如果((date.getMonth()=4)和&(date.getDate()=12)){ 返回[true,'sd special_day_20',“special\n tooltip\n here”]; } 如果((date.getMonth()=4)和&(date.getDate()=10)){ 返回[tr
- 在特定日期设置CSS宽度的样式(例如,内部有电源条)
- 在这些特定日期内添加多个元素
函数特殊日期(日期){
如果((date.getMonth()=4)和&(date.getDate()=12)){
返回[true,'sd special_day_20',“special\n tooltip\n here”];
}
如果((date.getMonth()=4)和&(date.getDate()=10)){
返回[true,'sd special_day_40',“special\n tooltip\n here”];
}
如果((date.getMonth()=4)和&(date.getDate()=21)){
返回[true,'sd special_day_90',“special\n tooltip\n here”];
}
返回[true',];
}
$('#datepicker')。datepicker();
$(“#datepicker”).datepicker('option','beforeShowDay',specialDate);
//在beforeShowDay事件之后模拟:
setTimeout(函数(){
$('.sd')。每个(函数(){
var classes=$.map($(this)[0]。类列表,函数(cls,i){
如果(cls.indexOf('special_day')==0){
返回cls.replace('特殊日','');
}
});
对于(var i=0;i您需要设置锚定标记位置:绝对;
及其父级位置:相对;
检查此修改
在一天中添加多个元素
更改代码-JS
$(".special_day a").append("<div></div><div></div>");
.special_day a {
color: red !important;
position: absolute;
left:0;
top:0;
width:200%;
}
.special_day div {
display:inline-block;
width:20px;
background: green;
height: 10px;
margin: 0px 2px;
}
.special_day {
position: relative;
}
你能再进一步解释一下吗?我刚才看到你可以为你的特定日子设置颜色。你想为这一天应用宽度吗?@TanDuong是的,但不知道怎么做..Gerardo我有一个来自js的值,想在这一天以某种方式显示:我想使用CSS伪选择器,attr()等,但看起来不简单,我恐怕你不能这样做,因为这是一个表。查看更多这里