我知道jquery将允许你用.attr()方法修改属性。基本上有两种方法:用jquery设置一个布尔属性
$('#element').attr('attribute', 'value') // sets the attribute
var attribute = $('#element').attr('attribute') // gets the attribute
我的问题是,你如何设置一个布尔属性,如在选择标签复选框或“多”“检查”?
我试着做没有成功如下:
$('#element').attr('attribute', true)
$('#element').attr('attribute', '')
所有这些添加的特性,但通常这样的<tag attribute="attribute">
。
在HTML5中不是这样:http://dev.w3.org/html5/spec/common-microsyntaxes.html#boolean - 属性 –
你是对的,我不应该做出这样的假设......道歉 –