学的越多感觉不会的越多。php+mysql学了点皮毛。知道搞web的是要会js的于是开始结合公司的项目开始学习js之旅(http://www.w3school.com.cn/b.asp)
1
2
3
4
5
6
7
|
$(document).ready( function (){
//do something
}); 在jq中就是 $ function (){
//do something
} |
submit事件
submit是弹出一个警告框用法:
1
2
3
4
5
|
$(document).ready( function (){
$( "from" ).submit( function (e){
alert( "123" );
});
}) |
val设置输入域的值
1
2
3
4
5
|
$(document).ready( function (){
$( "button" ).click( function (){
$( "input:text" ).val( "aa" );
});
} |
1
2
3
4
5
6
|
if ($( ‘#vdcode‘ ).val()== "" )
{
$( ‘#vdcode‘ ).focus();
alert( "验证码不能为空!" );
return
false ;
}
|
focus焦点改变文本框背景颜色
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
<html> <head> <script type= "text/javascript"
src= "/jquery/jquery.js" ></script>
<script type= "text/javascript" >
$(document).ready( function (){
$( "input" ).focus( function (){
$( "input" ).css( "background-color" , "#FFFFCC" );
});
$( "input" ).blur( function (){
$( "input" ).css( "background-color" , "#D6D6FF" );
});
}); </script> </head> <body> Enter your name: <input type= "text"
/>
<p>请在上面的输入域中点击,使其获得焦点,然后在输入域外面点击,使其失去焦点。</p> </body> </html> |
1
|
|