码迷,mamicode.com
首页 > 编程语言 > 详细

前端页面的语法 jquery javascript ajax

时间:2017-10-24 22:34:57      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:put   --   class   nbsp   不为   min   name   状态   selected   

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="../U2-5Linux技术/jquery-3.2.1.min.js" type="text/javascript"></script>

<script type="text/javascript">
	
	$(document).ready(function(){
		//选取td的文本内容中包含+的标签
		$("td:contains(‘+‘)").css("background","blue");
          //选取包含a标签的td标签 $("td:has(a)").css("background","pink");           //当提交按钮点击后触发的函数 $(":submit").click(function(){ //选取id id有特殊字符转义 //$("#id#2")-->$("#id\\#2") //$("#id\\#2").html("这是#id#2的文本内容"); //属性选择器的话就不用转义 //$("[id=‘id#2‘]").html("这是#id#2的文本内容"); //$("#id[2]")-->$("#id\\[2\\]")                //判断属性为text的标签的value属性的值长度为0的话 // if($(":text").val().length==0){ // alert(‘username为空‘) // };
               //判断属性为password的标签中的最后一个标签的value属性的值长度为0的话 // if($(":password:last").val().length==0){ // alert(‘确认密码都为空‘) // }
               //只有属性为text,password的标签 判断需要.val()才能得到文本能容 其它的不需要加入.val()
               //判断属性为radio的标签中属性为checked选中状态的标签的value属性的值不为0的话 if($(":radio:checked").length!=0){ alert($(":radio:checked").val()) }; if($(":checkbox:checked").length!=0){ alert($(":checkbox:checked").val()) };
               //判断选中下拉框一栏的value属性的值不等于""的话 if($(":selected").val()!=""){ alert($(":selected").val()) } }); });

    //javascript语法 当窗体加载时 // window.onload=function(){
          //得到元素id为username的标签 加上标签中的style的background背景颜色的值 并且alert弹窗 // var box1=document.getElementById("username"); // var box2="username:"+box1.style.background; // alert(box2);
          //通过定义的标签变量可以直接修改标签中属性的值 下面是修改style样式属性中的背景颜色和value属性的语法 简单粗暴 // box1.style.background="blue"; // box1.value="456"; // } </script> <style type="text/css"> .c{ color:red;} </style> </head> <body> <form method="post"> 姓名:<input type="text" name="username" value="2"/><br/> 密码:<input type="password" name="pwd"/><br/> 确认密码:<input type="password" name="querenpwd" /><br/> 性别:<input type="radio" name="gender" value="1"/>男 <input type="radio" name="gender" value="2"/>女 <br/> 爱好:<input type="checkbox" name="hobby" value="1"/>篮球 <input type="checkbox" name="hobby" value="2"/>足球 <input type="checkbox" name="hobby" value="3"/>羽毛球 <br/> 省份:<select> <option value="">请选择</option> <option value="yunnan">云南</option> <option value="wuhan">武汉</option> <option value="changsha">长沙</option> </select> <br/> <input type="submit"/><br/> </form> <table> <tr> <td><a href="#">123</a></td> <td>456</td> <td>245+</td> </tr> </table> </body> </html>

 

前端页面的语法 jquery javascript ajax

标签:put   --   class   nbsp   不为   min   name   状态   selected   

原文地址:http://www.cnblogs.com/m97i/p/7725871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!