首页 > 其他分享 >JQ 事件对象的属性

JQ 事件对象的属性

时间:2023-06-26 20:07:04浏览次数:40  
标签:function 对象 JQ click 效果图 html alert event 属性


demo.html

<html>
<head>
<title>event.type</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("a").click(function(event) {
		alert(event.type); //获取事件类型
		return false; //阻止链接跳转
	});
})
</script>
</head>
<body>
<a href='http://google.com'>click me .</a>
</body>
</html>

效果图:

JQ 事件对象的属性_xhtml


 

demo2.html

<html>
<head>
<title>event.target</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("a").click(function(event) {
		alert(event.target.href); //获取触发事件的<a>元素的href属性值
		return false; //阻止链接跳转
	});
})
</script>
</head>
<body>
<a href='http://google.com'>click me .</a>
</body>
</html>

效果图:

JQ 事件对象的属性_jquery_02


 

demo3.html

<html>
<head>
<title>event.pageX event.pageY</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("a").click(function(event) {
		alert("Current mouse position: " + event.pageX + ", " + event.pageY );//获取鼠标当前相对于页面的坐标
		return false;//阻止链接跳转
	});
})
</script>
</head>
<body>
<a href='http://google.com'>click me .</a>
</body>
</html>

效果图:

JQ 事件对象的属性_javascript_03


 

demo4.html

<html>
<head>
<title>event.which</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("a").mousedown(function(e){
		alert(e.which)  // 1 = 鼠标左键 left; 2 = 鼠标中键; 3 = 鼠标右键
		return false;//阻止链接跳转
	})
})
</script>
</head>
<body>
<a href='http://google.com'>click me .</a>
</body>
</html>

效果图:

JQ 事件对象的属性_jquery_04


 

demo5.html

<html>
<head>
<title>event.which2</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("input").keyup(function(e){
		alert(e.which);
	})
})
</script>
</head>
<body>
<input />
</body>
</html>

效果图:

JQ 事件对象的属性_ViewUI_05


 

demo6.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>event.metaKey</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.10.1.min.js" type="text/javascript"></script>
<script>
$(function(){
	$("input").keyup(function(e){
		alert(e.metaKey +" "+e.ctrlKey );
		$(this).blur();
	})
})
</script>
</head>
<body>
<input type="text" value="按住ctrl键,然后再点其他任何键" style="width:200px"/>
</body>
</html>

效果图:

JQ 事件对象的属性_ViewUI_06


 

 

 

标签:function,对象,JQ,click,效果图,html,alert,event,属性
From: https://blog.51cto.com/u_16171388/6557259

相关文章

  • JQ 移除事件
    demo.html<html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><styletype="text/css">*{margin:0;padding:0;} body{font-size:13px;line-hei......
  • JQ 自动加载页面
    demo.html<listyle="opacity:0;-moz-opacity:0;filter:alpha(opacity=0);"><p>---------------</p></li><listyle="opacity:0;-moz-opacity:0;filter:alpha(opacity=0);"><p>阅谁问君诵,水落清香浮</p></li>......
  • JQ 其它的点击事件用法
    demo.html<html><head><title></title><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><style>.over{ color:red; background:#888;}</style><scriptsrc="js/j......
  • JQ 复选框全选反选
    <!DOCTYPE><html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><scriptsrc="js/jquery-1.10.1.min.js"type="text/javascript">&......
  • JQ 多行文本框高度变化
    <html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>文本框高度变化</title><styletype="text/css">*{ margin:0; padding:0; font:normal12px/17pxArial......
  • JQ 下拉框左右选择
    <html><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title></title><styletype="text/css">*{ margin:0; padding:0;}div.centent{ float:left; text-......
  • JQ 表格展开伸缩
    style.csstable{border:0;border-collapse:collapse;}td{font:normal12px/17pxArial;padding:2px;width:100px;}th{font:bold12px/17pxArial;text-align:left;padding:4px;border-bottom:1pxsolid#333;width:100px;}.parent{background:#FFF38F;cursor:point......
  • JQ 瀑布流
    demo.css*{ padding:0; margin:0;}.wrap{ position:relative;}.box{ position:absolute; left:0; top:0; width:250px;}.boximg{ width:250px;} demo.js$(function(){ $('img').load(function(){ varbox=$('.box'); var......
  • JQ 可展开折叠的导航
    <!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>Document</title><style>*{padding:0;margin:0;}li{list-style-type:none;}body{margin:50px;font-family:\5FAE\8F6......
  • JQ 拖拽
    <!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><title>拖拽</title><style>*{ padding:0; margin:0;}div{ width:100px; height:100px; background:#f00; cursor:pointer; ......