发现自己以上答案都不适用于我,这是奇怪的,因为大多数人应该是完全合法的.
我发现工作实际上是
$('input[type="radio"]:not(:checked)')
在我的情况下,我需要
$('li input[type="radio"]:not(:checked) + label')
整个代码是:
//we'll need m for detecting a click outside of element with our radio buttons...
var m = false;
$(document).ready(function(){
$.ajax({
type: "GET",url: 'xml.xml',dataType: 'xml',success: function(data){
var xml = $(data);
$('#windowList').append( ItemToUl(xml.children()) );
}
});
$('.calc').hover(function(){
m=true;
},function(){
m=false;
});
$("body").mousedown(function(){
if(! m) {
//...and unchecking a checked radio. I heard that .attr() was deprecated but couldn't get .prop() to work
$('li input[type="radio"]:checked').attr('checked',false);
$('li input[type="radio"]:not(:checked) + label').fadeTo('slow',1);
}
});
$("li input").live("change",function(){
$('li input[type="radio"]:checked + label').fadeTo('slow',1);
$('li input[type="radio"]:not(:checked) + label').fadeTo('slow',0.45);
});
});
//constructing function,etc...