【发布时间】:2018-03-28 21:53:45
【问题描述】:
我有打字稿代码
这里是
$('.Switch').on('click', function() {
if ($(this).hasClass('On')) {
$(this).parent().find('input:checkbox').attr('checked', true);
$(this).removeClass('On').addClass('Off');
$(this).parent().find('input:hidden').val(0);
$(".filter_stops").each(function() {
if ($(this).slider( "option", "value" ) === 0) {
$(this).off('slidechange');
$(this).slider( "option", "value", 99 );
$(`#stops_${this.id.split('_')[1]}`).val(`Max ${$( this ).slider("value")} ${__('byten')}`);
$(`#filter_stops_${this.id.split('_')[1]}`).val($( this ).slider("value"));
$(this).on('slidechange', FilterFunctions.onFilterChange);
}
});
在这段代码中我有 2 个错误
在这一行$(this).parent().find('input:checkbox').attr('checked', true);我有
'true' 类型的参数不能分配给 '(index: number, attr: string) => string | 类型的参数号码”。
在这个
$(`#stops_${this.id.split('_')[1]}`).val(`Max ${$( this ).slider("value")} ${__('byten')}`);
类型“TElement”上不存在属性“id”。
我该如何解决?
【问题讨论】:
-
请分享您的html代码
-
使用
$(this).parent().find('input:checkbox').prop('checked', true);而不是$(this).parent().find('input:checkbox').attr('checked', true); -
是的。它修复了第一个错误。但是我能用第二个做什么?@SupunFictionPraneeth
标签: javascript jquery typescript