-1
有两个标签,我希望他们旋转点击。我用JQuery来做到这一点,但它只适用于第一次点击! 我怎样才能使它在每次点击上都有效?Jquery-添加css onclick只在第一次点击时工作
$(document).ready(function() {
$(document).on("click", "#male", function() {
$('#male i').css({
'transform': 'rotate(360deg)'
})
})
});
#male i,
#female i {
transition: 1s;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<label id="male" class="pull-left text-center col-md-5 btn btn-default" style="height: 36px;">
<i class="fa fa-2x fa-male text-center" style="color: tomato">
<input type="radio" name="gender" value="male" checked>
</i>
</label>
<label id="female" class="pull-right text-center col-md-5 btn btn-default" style="height: 36px;">
<i class="fa fa-2x fa-female text-center" style="color: purple">
<input type="radio" name="gender" value="female">
</i>
</label>
它还对每次点击的工作。第一次单击将图标从0旋转到360.第二次单击图标并将其从360旋转到360. – zzzzBov
@zzzzBov哦该死!你是对的!谢谢 – soheil