Skip to content

Instantly share code, notes, and snippets.

@tigawa
Last active August 29, 2015 14:13
Show Gist options
  • Save tigawa/3a4899e3b837a8f3baf2 to your computer and use it in GitHub Desktop.
Save tigawa/3a4899e3b837a8f3baf2 to your computer and use it in GitHub Desktop.
JQueryでbutton, linkを無効にする方法
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://fgnass.github.io/spin.js/spin.min.js"></script>
<script type="text/javascript" src="http://fgnass.github.io/spin.js/jquery.spin.js"></script>
<script type="text/javascript">
/* 共通処理 START*/
$(document).on('click', '.submit', function(evnet){
var opts = {
lines: 15, // The number of lines to draw
length: 9, // The length of each line
width: 3, // The line thickness
radius: 9, // The radius of the inner circle
corners: 0.2, // Corner roundness (0..1)
rotate: 50, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
};
$(this).spin(opts);
all_btn_disabled();
});
$(document).on('click', 'a.disabled', function(evnet){
return false;
});
function all_btn_disabled(){
$(':submit,button').attr("disabled", "disabled");
$('a').addClass('disabled');
}
/* 共通処理 END */
</script>
</head>
<body>
<form>
<ul>
<li><input type="text"></li>
<li><input id="c1" class="submit" type="submit" value="登録"></li>
<li><button class="submit">登録ボタン2</button></li>
<li><a href="javascript:alert('!!')" class="submit">リンク登録</a></li>
</ul>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment