jQuery基础代码练习

html<html<head lang="en"<meta charset="UTF-8"<titletitlehead<body<h1h1<brbr<div id="div1"<divdiv<div<divdivdiv<div<divdiv<divdivdiv<divdivdiv<brbr<ol<lili<lili<liliol<hr<script src="../jQuery/jquery-1.12.2.min.js"script<script$("div div:last").css("color","orange");
($("div div div:first-child").css("font-size","24px"));
alert($("div div div").length);
script<brbr<form action="#"<input type="text" οnblur="aa()"<br<input type="password" οnblur="bb()"<brform<brbr<ol<lili<liliol<script src="../jQuery/jquery-1.12.2.min.js"script<scriptfunction aa(){
if($("form input").eq(0).val()==""){
$("form input").eq(0).val("请输入姓名:");
}
else{
alert($("form input").eq(0).val());
}
}
function bb(){
var changdu=$("form input").eq(1).val().length;
if(changdu>20){
var num= $("form input").eq(1).val().substr(0,20);
$("form input").eq(1).val(num);
}
}
scriptbodyhtml>

转载于:https://www.cnblogs.com/huzjijie/p/6590601.html

你可能感兴趣的:(jQuery基础代码练习)