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

asp.net使用jquery實現(xiàn)搜索框默認提示功能

 更新時間:2014年01月13日 11:39:43   作者:  
這篇文章主要介紹了asp.net使用jquery實現(xiàn)搜索框默認提示功能,大家參考使用吧

文本框中創(chuàng)建默認文本提示

通常用戶在搜索內(nèi)容時,在文本框輸入內(nèi)容前,文本框都會給出默認提示,提示用戶輸入正確的內(nèi)容進行搜索。

當文本框獲得焦點,如果文本框內(nèi)容跟提示內(nèi)容一樣,提示內(nèi)容會自然消失。

當文本框沒有任何值并失去焦點,文本框內(nèi)容會重新生成默認提示。

為了實現(xiàn)上面的需求,代碼如下:

復制代碼 代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Web.Default" %>

<!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></title>
    <script src="jquery-1.8.2.min.js" type="text/javascript"></script>
    <link href="Base.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .text
        {
            border: #0a8fda solid 1px;
            color: #cccccc;
            font-style:italic;
            background: #fff url(img/input.gif);
            padding: 5px;
        }
        .text-focus
        {
            border: solid 1px #f50;
            background: #fff url(img/input.gif);
            padding: 5px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            var txtSearch = $("#<%=txtSearch.ClientID%>");

            $("#txtSearch").focus(function () {
                if (txtSearch.val() == this.title) {
                    txtSearch.val("");

                    this.className = "text-focus";
                }
            });

            $("#txtSearch").blur(function () {

                if (txtSearch.val() == "") {
                    txtSearch.val(this.title);
                    this.className = "text";
                }
            });
            txtSearch.blur();
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="margin: 100px auto; width: 400px; height: 80px;border: solid 1px #0a8fda;">
        <p style="text-align:center;">
            <asp:TextBox ID="txtSearch" runat="server" Width="200px" class="text" ToolTip="請輸入搜索的關鍵字"></asp:TextBox>
            <asp:Button ID="btnSearch" runat="server" Text="搜索" class="button blue" />
        </p>
    </div>
    </form>
</body>
</html>

相關文章

最新評論

临颍县| 台南市| 西藏| 西畴县| 莱阳市| 酉阳| 抚州市| 肥西县| 毕节市| 绥中县| 海宁市| 海宁市| 修文县| 昭平县| 泸溪县| 乌拉特中旗| 侯马市| 永寿县| 武义县| 绥中县| 社旗县| 定襄县| 辽宁省| 长宁县| 大余县| 博罗县| 平定县| 扶绥县| 星座| 辽阳市| 兴安县| 宝坻区| 彭泽县| 黄骅市| 高台县| 翁牛特旗| 雷山县| 徐汇区| 阿尔山市| 响水县| 南安市|