<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>Title</title>
		<script src="js/jquery-3.5.1.min.js"></script>
		<script>
            $(function () {
                var flag = 1;
                $('div').on('click', function () {
                    if (flag == 1)
                        $(this).css('backgroundColor', 'red')
                    else
                        $(this).css('backgroundColor', 'pink')
                    flag = -flag;
                })
	            /*元素.事件*/
	            // $('div').click();

	            /*元素.trigger(事件)*/
	            // $('div').trigger('div')

	            /*元素.triggerHandler('事件') 不会触发元素默认行为*/
	            $('div').triggerHandler('click')

	            $('input').on('focus',function () {
		            $(this).val('你好吗')
                })
                // $('input').trigger('focus')     //光标闪烁
                $('input').triggerHandler('focus'); //光标不会闪烁
            })
		</script>
		<style>
			div {
				height: 100px;
				width: 100px;
				background-color: pink;
			}
		</style>
	</head>
	<body>
		<div></div>
		<input type="text">
	</body>
</html>