六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 79|回复: 0

jquery属性

[复制链接]

升级  62%

41

主题

41

主题

41

主题

秀才

Rank: 2

积分
143
 楼主| 发表于 2013-2-7 19:20:55 | 显示全部楼层 |阅读模式
<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>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表