最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP.NET jQuery 實(shí)例1(在TextBox里面創(chuàng)建一個(gè)默認(rèn)提示)

 更新時(shí)間:2012年01月13日 22:12:56   作者:  
通常用戶在搜索內(nèi)容時(shí),在文本框輸入內(nèi)容前,文本框都會(huì)給出默認(rèn)提示,提示用戶輸入正確的內(nèi)容進(jìn)行搜索
當(dāng)文本框獲得焦點(diǎn),如果文本框內(nèi)容跟提示內(nèi)容一樣,提示內(nèi)容會(huì)自然消失。
當(dāng)文本框沒有任何值并失去焦點(diǎn),文本框內(nèi)容會(huì)重新生成默認(rèn)提示。
為了實(shí)現(xiàn)上面的需求,代碼如下:
復(fù)制代碼 代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Recipe1.aspx.cs" Inherits="Recipe1" %>
<!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 runat="server">
<title>Recipe1</title>
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<style type="text/css">
.defaultText
{
font-style: italic;
color: #CCCCCC;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
var searchBox = $("#<%=txtSearch.ClientID %>"); // 通過ClientID獲取服務(wù)器控件ID
searchBox.focus(function () {
if (searchBox.val() == this.title) { // TextBox控件ToolTip屬性轉(zhuǎn)換為Html為title屬性
searchBox.val("");
searchBox.removeClass("defaultText");
}
});
searchBox.blur(function () {
if (searchBox.val() == "") {
searchBox.val(this.title);
searchBox.addClass("defaultText");
}
});
searchBox.blur();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<p>
</p>
<div align="center">
<fieldset style="width: 400px; height: 80px;">
<p>
<asp:TextBox ID="txtSearch" runat="server" Width="200px" CssClass="defaultText" ToolTip="請(qǐng)輸入搜索的關(guān)鍵字"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="搜索" /></p>
</fieldset>
</div>
</form>
</body>
</html>

顯示效果:

 

相關(guān)文章

最新評(píng)論

密山市| 三都| 东兰县| 通州市| 花莲市| 株洲市| 琼结县| 正蓝旗| 江山市| 锦州市| 舒城县| 浦城县| 依安县| 夏津县| 北海市| 长乐市| 南城县| 平潭县| 陇西县| 安岳县| 德格县| 涡阳县| 乌苏市| 洞头县| 三穗县| 忻州市| 锡林郭勒盟| 黎川县| 郧西县| 台前县| 银川市| 石首市| 桓仁| 双牌县| 崇文区| 罗源县| 汉中市| 滕州市| 图木舒克市| 武定县| 泰顺县|