$('<option selected="selected">something</option>')
.removeAttr('selected')
.wrap('<p></p>').parent().html();
结果是
<option>something</option>
这是预期的。但是,如果我在删除“selected”属性后将其放回(或<option>没有“selected”属性的标签),我会得到相同的输出。
$('<option selected="selected">something</option>')
.removeAttr('selected')
.attr('selected', 'selected')
.wrap('<p></p>').parent().html();
为什么会这样?