我想設置一個無線電檢查到一個類的div和鼠標所有以前的div上,並刪除鼠標。麻煩的是,它設置爲圍繞每個div的'a'標籤。jQuery設置類到內部div
有沒有辦法設置爲內部div?
$(function() {
$('.radio-fx').live("mouseenter", function() { // Handles the mouseover
var $self = $(this);
$self.addClass('radio-checked').prevAll().addClass('radio-checked');
$self.nextAll().removeClass('radio-checked');
}).live ("mouseout", function() { // Handles the mouseout
$(this).removeClass('radio').prevAll().removeClass('radio');
});
});
<div class="voteGroup">
<input type="radio" id="price_0" value="1" name="price" style="display: none;" class="radio-checked">
<a href="#" class="radio-fx price radio-checked" title=" check me ">
<div class="radio"></div>
</a>
<input type="radio" id="price_1" value="2" name="price" style="display: none;" class="radio-checked">
<a href="#" class="radio-fx price radio-checked" title=" check me ">
<div class="radio"></div></a>
<input type="radio" id="price_2" value="3" name="price" style="display: none;" class="radio-checked">
<a href="#" class="radio-fx price radio-checked" title=" check me ">
<div class="radio"></div>
</a>
<input type="radio" id="price_3" value="4" name="price" style="display: none;" class="radio-checked">
<a href="#" class="radio-fx price radio-checked" title=" check me ">
<div class="radio"></div>
</a>
<input type="radio" id="price_4" value="5" name="price" style="display: none;" class="radio-checked" checked="checked">
<a href="#" class="radio-fx price radio-checked" title=" check me ">
<div class="radio-checked"></div>
</a>
</div>
你能否給我們提供一個可用的http://jsfiddle.net/例子? – ZeroOne