Skip to content

Instantly share code, notes, and snippets.

/sippai.js Secret

Created July 18, 2012 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/833b7bf71869f5cf827c to your computer and use it in GitHub Desktop.
Save anonymous/833b7bf71869f5cf827c to your computer and use it in GitHub Desktop.
はてな質問用
$(function(){
$('label img').toggle(
function () {
var onSrc = $(this).attr('src').replace('.png', 'kakikae.png');
$(this).attr('src', onSrc);
},
function () {
var onSrc = $(this).attr('src').replace('kakikae.png', '.png');
$(this).attr('src', onSrc);
}
);
});
<div>
<input type='checkbox' name='ck2' id='a1' >
<label for='radio1' >
<img src='http://test.png'/>
</label>
<input type='checkbox' name='ck2' id='a1' >
<label for='radio2' >
<img src='http://test.png'/>
</label>
</div>
$(function(){
$('label').toggle(
function () {
$(this)
.addClass('checked')
.prev('input').attr('checked','checked');
},
function () {
$(this)
.removeClass('checked')
.prev('input').removeAttr('checked');
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment