|
<html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> .high{font-weight:bold;color:red } .another{font-style:italic;color:green } </style> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript">$(document).ready(function(){$("input:eq(0)").click(function(){ //为所有匹配的元素设置一个属性值。//addClass为每个匹配的元素添加指定的类名。$("p").attr("class","high");});$("input:eq(1)").click(function(){$("p").toggleClass("another");});$("input:eq(2)").click(function(){alert($("p").html());});});================================================ $(document).ready(function(){$("#username").focus(function(){//设置每一个匹配元素的值。var value =$(this).val();//if(value=="username")if(value==this.defaultValue){$(this).val("");}});$("#username").blur(function(){var value=$(this).val();if(value==""){//$(this).val("username");$(this).val(this.defaultValue);}}); }); </script> |
|