jQuery(3-7)属性操作

jQuery(3-7)属性操作jQuery(3-7)属性操作jQuery(3-7)属性操作

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>属性操作.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

<script type="text/javascript" src="../jquery-1.7.1.js"></script>
</head>
<style>
.wid{
width: 150px ;
color: purple ;
font-weight: bold;; <!-- 粗体字 -->
}
.hei{
height: 150px;
}
.another{
font-style: italic;<!-- 斜体 -->

}
</style>

<body>
<h3><br></h3><h3>水果</h3>
<strong title="mouse">老鼠掉进大米缸</strong>
<strong title="cat">正好大米缸里面有只猫··哎····</strong>

<p class="wid" title="选择你喜欢的水果"> 你喜欢的水果是?</p>
<ul style="background-color: purple">
<li title ="苹果 ">苹果</li>
<li title ="橘子 ">橘子</li>
<li title ="菠萝 ">菠萝</li>
<li title ="香蕉 ">香蕉</li>
<li title ="梨子 ">梨子</li>
</ul>

</body>
<script type="text/javascript">
/* $(function(){
$('p').attr("title","your title"); //获取 p元素 节点属性 为 title 给值
});
*/


/*$(function(){
var $a = $('p').html(); //html()读取还可以 设置 某个 元素中的内容
alert($a); //打印 类容
$('p').html('<strong>猪猪猪猪 </strong>'); //设置类容
});
*/

/*$(function(){
var $a = $('p').text(); //text()读取还可以 设置 某个 元素中的内容
alert($a); //打印 类容
$('p').text('<strong>猪猪猪猪 </strong>'); //设置类容 晕 这个连 标签都可以打印出来 厉害 完全文本输出
});
*/

$(function(){

$('p').removeAttr('title'); //删除p元素中的title属性

/*

<p class="wid" title="选择你喜欢的水果"> 你喜欢的水果是?</p>

删除后

<p class="wid" > 你喜欢的水果是?</p>

*/

});


</script>

</html>