2013-04-15 20 views

回答

1

Inside change事件处理程序$(this)是指DatePicker而不是原来的input。所以你应该使用$(this.element)来代替。

$("#date").kendoDatePicker({ 
    change: onChange 
    } 
}); 

function onChange(e) { 
    if (!e.sender.value()) { 
     $(this.element).closest('span').addClass("myclass"); 
     $(this.element).parent('span').addClass("myclass"); 
     // NOTE: The following will actually not work since it does not have child 
     // $(this.element).child('span').addClass("myclass"); 
    } 
} 

编辑:并定义样式:

.myclass { 
    border: 3px solid red !important; 
} 

运行例如这里:http://jsfiddle.net/OnaBai/Csp6P/

+0

这个人是不是添加红色边框我的日期选择器? – InTheWorldOfCodingApplications

+0

请参阅我的**编辑** – OnaBai

+0

这个作品,非常感谢。 – InTheWorldOfCodingApplications

相关问题