<!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 type="text/css">
.wid{
width: 150px ;
color: purple ;
font-weight: bold;; <!-- 粗体字 -->
}
.hei{
height: 150px;
}
.another{
font-style: italic;<!-- 斜体 -->
}
</style>
<body>
<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>
<input type="text" id = "username" value = "请输入用户名 " />
<input type="text" id = "password" value = "请输入密码 " />
<input type ="button" id ="button" value="登录 " />
<select id = "one" multiple="multiple">
<option value="1" selected="selected" > 哈哈</option>
<option value="2">呵呵 </option>
<option value="3"> 嘿嘿</option>
<option value="4" > 嘎嘎</option>
</select>
</body>
<script type="text/javascript">
//html()方法 设置值 和 取值
/* $(function(){
var p_html = $('p').html(); // html()获取<p>元素的 HTML代码
alert(p_html); //打印 <p> 元素 中的内容
$('p').html('<font color="blue">冰封蓝叶</font> ');//重新 设置 <p>元素中的内容
//设置新的内容就是添加一个新的元素 在新元素中给内容
});*/
//text()方法 设置值 和 取值
/* $(function(){
var p_text = $('p').text(); // text()获取<p>元素的 HTML代码
alert(p_text); //打印 <p> 元素 中的内容
$('p').text('冰封蓝叶');//重新 设置 <p>元素中的内容
//text()给可以直接给值 不需要重新添加新元素
})*/
//val()取值 操作
/* $('#username').focus(function(){
var getname = $(this).val(); //获取文本框中的值
//alert(getname);打印值
if(getname == this.defaultValue){ //defaultValue 默认取得文本框的类容
$(this).val("");
}
});*/
$(function(){
//$('#one').val('3'); //选择下拉框的数据
$('#one').val(['1','3']); //多选方式
});
</script>
</html>