我在我的页面中为每个需要它的输入使用了一些日期选择器,
但有时会禁用某些字段。
如果输入被禁用,我想删除所有日历和datepicker图标
我尝试过类似的东西
if($(".datepicker").prop('disabled')){
$(this).removeClass('datepicker');
}
在document.ready函数等中......
但它不起作用
另外,datepicker图标有一个特定的类
<img class="ui-datepicker-trigger" src="images/calendar-day.png" alt="..." title="...">
我需要的是删除所有输入被禁用的图片,因为用户可以打开日期选择器并更改日期。
非常感谢任何帮助。
答案 0 :(得分:2)
使用此CSS规则:
input.hasDatepicker[disabled] + img.ui-datepicker-trigger {
display: none;
}
答案 1 :(得分:1)
像这样 -
$(".datepicker").each(function(){
if($(this).prop('disabled')){
$(this).find('.ui-datepicker-trigger').hide();
}
});