The question is asked in a misleading manner. "Removing the selected
attribute" and "deselecting all options" are entirely different things.
To deselect all options in a documented, cross-browser manner use either
$("select").val([]);
or
// Note the use of .prop instead of .attr
$("select option").prop("selected", false);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…