<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
	<style>
		input{
			transition: 1s;
			width: 200px;
		}
		.bewider{
			width: 500px;
		}
	</style>
</head>	
<body>
<input type="text" name="">
<button>按下我的效果跟input被focus的效果一樣</button>
<script type="text/javascript">
	$(function(){
		$('input').focus(function(){
			$(this).addClass('bewider');
		}).blur(function(){
			$(this).removeClass('bewider');
		});
		$('button').click(function(){
			$('input').trigger('focus');
		});
	});
</script>
</body>
</html>

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Jerry 的頭像
    Jerry

    Bug倉庫 // 程式日記

    Jerry 發表在 痞客邦 留言(0) 人氣()