jqueryで画像上にマウスがあり、チェックされた画像の機能を持つチェックボックスフォームを作りたいと思います。jqueryを使用したチェックボックスの画像フォーム
私は正常に機能しましたが、一緒に機能しませんでした。
ここは私のhtml形式です。ここで
<label for="w_interest">
<img src="/images/account/w_select.png_img"/ style='cursor:pointer;'>
<input name="w_interest" type="checkbox" id="w_interest" style="display:none">
</label>
は、ユーザが画像上にマウスに、画像上の画像の変化を、それらのマウスポインタを移動jqueryの
$(document).ready(function() {
$('#w_interest').hover(
function() {
$('img', this).attr('src', '/images/account/w_select_hover.png');
},
function() {
$('img', this).attr('src', '/images/account/w_select.png');
}
);
$("#w_interest").change(function() {
if(this.checked) {
$(this).prev().attr("src", "/images/account/w_select_checked.png");
} else {
$(this).prev().attr("src", "/images/account/w_select.png");
}
});
});
あります。
イメージをクリックすると、チェックされたイメージに変わります。 (もちろん、チェックボックスをチェックします)
私はこれらの2つの機能を組み合わせて実現することができますか?
?あなたはリンクやjsfiddleの例を提供できますか? – rgin