JavaScript, jQueryサンプル

コピペや切り取りを禁止したい

解説ブログ:http://ultrah.zura.org/?p=7183





■個別に指定

HTML

<input type="text" id="target1">

jQuery

$(document).ready(function(){
	// 個別に指定
	$('#target1').on('paste',function(){
		return false;
	}).on('copy',function(){
		return false;
	}).on('cut',function(){
		return false;
	});
});

■まとめて指定

HTML

<input type="text" id="target2">

jQuery

$(document).ready(function(){
	// まとめて指定
	$('#target2').on('copy cut paste',function(e){
		e.preventDefault();
	});
});





トップ | Contact