jquery-attr属性添加实例

<!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>
</head>

<body>
<script type=”text/javascript” src=”jquery-1.8.0.js”></script>

<script type=”text/javascript”>
$(document).ready(function() {
  $(“img”).attr(“src”,”test.jpg”); 
  $(“.img2″).attr({src:”test.jpg”,alt:”Test Image”,title:”Test Image”});
  //$(“p”).removeAttr(“title”); 
});

</script>

<div id=”panel”>
 <h5 style=”cursor:hand;”>什么是jQuery?</h5>
 <div style=”display:none;”>jQuery是继Prototype之后又一个优秀的JavaScript库!</div>
    </div>
   
    <img/>
    <img/>
</body>
</html>

此条目发表在jquery参考分类目录。将固定链接加入收藏夹。

发表评论

邮箱地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>