jQuery入门
来源:互联网 发布:非法集资判定知不知情 编辑:程序博客网 时间:2024/05/17 00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>form.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script language="JavaScript" src="./js/jquery-1.4.2.js"></script> </head> <body> <input type="text" value="zhang" id="username" name="username" /> </body> <script language="JavaScript"> //测试 //使用document输出// var username = document.getElementById("username");// // alert(username.value); //使用JQuery输出 /* * jquery对象:需要用"$"来修饰 * * jquery获取页面标签:$()来包裹,通过"#id"来获取 * */ var $username = $("#username");//document.getElementById("username"); alert($username.val()); ////username.value </script></html>
dom转化为JQUery对象
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>form.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script language="JavaScript" src="./js/jquery-1.4.2.js"></script> </head> <body> <input type="text" value="zhang" id="username" name="username" /> </body> <script language="JavaScript"> //dom转化为JQUery对象 $(DOM对象) var username = document.getElementById("username"); var $username = $(username); alert($username.val()); </script></html>
JQUERY对象转化为DOM对象
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>form.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script language="JavaScript" src="./js/jquery-1.4.2.js"></script> </head> <body> <input type="text" value="zhangxx" id="username" name="username" /> <input type="text" value="zhangsanfeng" id="username1" name="username" /> </body> <script language="JavaScript"> //JQUERY对象转化为DOM对象 //方法一:jquery对象是一个数组对象,获取利用索引值进行转换成DOM对象 var $username = $("#username");// var username = $username[0];// // alert(username.value); //方法二:在jquery中,提供了一个get(index)方法,get()中传入索引值,来进行转换成DOM对象 var username = $username.get(0); alert(username.value); </script></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>form.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script language="JavaScript" src="./js/jquery-1.4.2.js"></script> </head> <body> <input type="text" value="zhang" id="username1" name="username1" /> <input type="text" value="88888" id="psw" name="psw" /> </body> <script language="JavaScript"> //dom,提示:缺少对象,需要手动判断 // var username = document.getElementById("username");// if(!username){// alert("id不存在");// }else{// alert(username.value);// } //jquery,有相对完善的对事件处理的机制 var $username = $("#username111"); alert($username.val()); </script></html>
0 0
- jQuery入门
- jQuery入门
- jQuery 入门
- jquery 入门
- jQuery 入门
- Jquery 入门
- jquery 入门
- jQuery 入门
- JQuery 入门
- jquery 入门
- jquery入门
- jQuery入门
- JQuery 入门
- jquery入门
- jQuery入门
- JQuery入门
- jQuery 入门
- jQuery 入门
- [js点滴]JavaScript事件Event对象03
- email邮件发送
- android知识回顾----观察者模式理解和举例
- 关于哈希的几个概念
- bzoj1644: [Usaco2007 Oct]Obstacle Course 障碍训练课
- jQuery入门
- Eclipse4.X版本安装fatjar插件(luna mars 版本均可用)
- 小白笔记----------------leetcode(404. Sum of Left Leaves )
- 文件的范例
- [js点滴]JavaScript之鼠标事件04
- Unknown tag (c:forEach) 未知的标签 解决方法
- Spring4.3.3 WebSocket-STOMP协议集成 (1.1)-WebSocket协议通讯小栗子
- Tensorflow:tf.train.SyncReplicasOptimizer
- UVa839-Not so Mobile (天平)