Skip to content

Instantly share code, notes, and snippets.

@masuhajime
Created March 12, 2015 06:30
Show Gist options
  • Save masuhajime/e7b8b4cab6c6037f1bbe to your computer and use it in GitHub Desktop.
Save masuhajime/e7b8b4cab6c6037f1bbe to your computer and use it in GitHub Desktop.
html中の<input type="radio"> をランダムに選択するBookMarklet
javascript:(function(){var url='//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js';if(!url.match(/\?/))url+='?t='+(new Date()).getTime();var d=document;var e=d.createElement('script');e.charset='utf-8';e.src=url;d.getElementsByTagName('head')[0].appendChild(e);function shuffle(t){for(var n,u,h=t.length;h;)u=Math.floor(Math.random()*h--),n=t[h],t[h]=t[u],t[u]=n}var inputs=[];$("input[type=radio]").each(function(){inputs.push($(this))}),shuffle(inputs);for(var j=0;j<inputs.length;j++)inputs[j].prop("checked",!0);})();
@masuhajime
Copy link
Author

作り甘いので2回位おした方がいいかも

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment