日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MyJquery

發(fā)布時間:2024/6/21 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MyJquery 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

???????????????????????????????????????????????????????????? Jquery??

  • 防止緩存對數(shù)據(jù)顯示的影響
  • ????? $.ajaxSetup({ cache: false });

  • Checkbox 獲取是否checked 與 Change
  • <asp:CheckBox ID="chkFeedback" runat="server" CssClass="csschkFeedback" />

    ?

    <span id="divReplyCode" style="display: none">

    <asp:Label….

    <asp:TextBox…

    </span>

    ?

    ----初始化

    ??? if ($(".csschkFeedback input").prop('checked')) {

    ??????? $('#divReplyCode').show();

    }

    ??? ?else {

    ?????? ?????$('#divReplyCode').hide();

    ?? }

    ???? ----綁定change 事件

    ??? $(".csschkFeedback input").change(function() {

    ??????? if ($(this).prop('checked')) {

    ??????????? $('#divReplyCode').show();

    ??????? }

    ??????? else {

    ??????????? $('#divReplyCode').hide();

    ??????? }

    ??? });

    ?

    ?

    ?

  • 全局文檔執(zhí)行結(jié)束后執(zhí)行的函數(shù)
  • $(function() {

    ??? ..events..

    });

    ?

    ?

    ?

    ?

    ?

    ?

  • Radio獲取是否checked 與 Change
  • ????????????? ?<asp:RadioButton ID="rbnNow" runat="server" GroupName="grpSendTime" Text="Now/及時發(fā)送"

    ??????????????????????? Checked="true" CssClass="cssRbnNow" />

    ?

    ??? if ($('.cssRbnNow input').prop('checked')) {

    ??????? $('#divCalendar').hide();

    ??? }

    ??? else {

    ??????? $('#divCalendar').show();

    }

    ??? $(".cssRbnNow input").change(function() {

    ??????? if ($(this).attr('checked')) {

    ??????????? $('#divCalendar').hide();

    ??????? }

    ??????? else {

    ??????? $('#divCalendar').show();

    }

    });

    ?

    ?

  • ?文本框 賦值和獲取值
  • ? <asp:TextBox ID="txtRecipients" runat="server" Width="500px" CssClass="txtAutoComplete"

    ??????????????????? TextMode="MultiLine" Rows="3"></asp:TextBox>

    ?

    ?

    ----值空

    ? $(".txtAutoComplete").val("");

    --讀取值

    var txtRecipients = $(".txtAutoComplete").val();

    --- 綁定事件

    ?

  • 自動提醒功能
  • ?

    ?

    ?

    ?

    ?

    ?

    ?

  • 綁定事件
  • ?? <asp:Button ID="btnSubmit" runat="server" Text="Submit/提交" OnClick="btnSubmit_Click"

    ??????????????????? CssClass="smsBtnSubmit" />

    ?

    $(".smsBtnSubmit").click(function() {

    ?

    ?

    ??????? //003 Get aprrovalCount

    ??????? var approvalCount = "";

    ??????? $.ajax({

    ??????????? type: "GET",

    ??????????? async: false,

    ??????????? url: 'GetContactData.aspx?Action=GetFlowApproveCountAction&Parms=' + msgType, //SMS and MMS should get this configuration from differenct db records, edit by eric

    ??????????? success: function(data) {

    ??????????????? if (data != "") {

    ??????????????????? approvalCount = data;

    ??????????????? }

    ??????????? },

    ??????????? error: function(err) {

    ??????????????? approvalCount = 200;

    ??????????? }

    ??????? });

    ??

    ?

    });

    ?

    ?????? ?????string action = Request["Action"];

    ??????????? if (!string.IsNullOrEmpty(action) && action == "GetFlowApproveCountAction")

    ??????????? {

    ??????????????? var parms = Request.QueryString["Parms"];

    ??????????????? int msgType = 0;

    ??????????????? if (!string.IsNullOrEmpty(parms))

    ??????????????? {

    ??????????????????? int.TryParse(parms, out msgType);

    ??????????????? }

    ??????????????? string strRes = GetFlowApproveCount(msgType);

    ??????????????? Response.Write(strRes);

    ??????????????? Response.End();

    ???? ???}

    ?

  • JS 讀取webconfig
  • ?? ??<appSettings>

    ??? <add key="DefaultSignature" value="【羅氏診斷】"/>?? ?

    ?? </appSettings>

    ?? ????function ReadSignatureSettingsFromWebConfig() {

    ??????? var DefaultSignatrue = '<%=ConfigurationManager.AppSettings["DefaultSignature"].ToString() %>'

    ??????? if (DefaultSignatrue == null || DefaultSignatrue == undefined || DefaultSignatrue == "") {

    ??????????? DefaultSignatrue = "【掉的大】";

    ??????? }

    ??????? return DefaultSignatrue;

    }

    ?

  • 打開樣式
  • ???????? <div id="dialog-form" title="Select Templete/選擇模板" style="display: none">

    ??? <div>

    ??????? <table width="100%" border="0" cellspacing="0" bgcolor="#E5E5E5">

    ??????????? <tr>

    ??????????????? <td>

    ??????????????????? <div id="divAllTempleteList" runat="server">

    ??????????????????? </div>

    ??????????????? </td>

    ??????????? </tr>

    ??????? </table>

    ??? </div>

    </div>

    ??? private void GettingSMSTemplates()

    ??????? {

    ??????????? this.divAllTempleteList.InnerHtml = _smsSendlogic.GetSMSTemplates(AppContext.Current.Roles, AppContext.Current.UserID, AppContext.Current.Department);

    ??????? }

    ?

    ??????? public string GetSMSTemplates(IEnumerable<string> roles, string userID, string department)

    ??????? {

    ??????????? List<SMSTemplateDTO> listRes = service.GetSMSTemplates(roles, userID, department).ToList();

    ??????????? string res = GetSelectTempleteContent(listRes);

    ??????????? return res;

    ??????? }

    ??????? private string GetSelectTempleteContent(List<SMSTemplateDTO> listRes)

    ??????? {

    ??????????? StringBuilder sb = new StringBuilder();

    ??????????? if (listRes.Count > 0)

    ??????????? {

    ??????????????? sb.Append("<table style=\"width:100%;line-height:25px\" cellspacing=\"0\" cellpadding=\"0\" bordercolorlight=\"#C0C0C0\" bordercolordark=\"#FFFFFF\">");

    ??????????????? for (int i = 0; i < listRes.Count; i++)

    ??????????????? {

    ??????????????????? sb.AppendFormat("<tr><td? style=\"vertical-align:top;width:20px;\"><input type=\"radio\" name=\"radioName\" value='group' /><textarea id=\"messageTextarea{0}\" style=\" height:100%; display:none;\" >{1}</textarea></td>",

    ??????????????????????? i, listRes[i].SMSContent);

    ??????????????????? sb.AppendFormat("<td>{0}</td></tr>", HttpUtility.HtmlEncode(listRes[i].Title));

    ??????????????? }

    ??????????????? sb.Append("</table>");

    ??????????? }

    ??????????? return sb.ToString();

    ??????? }

    ?

    <input type="button" id="selectTemplete" value="Select Templete/選擇模板" />

    ?

    ??????? $("#selectTemplete")

    ??????????? .button()

    ??????????? .click(function() {

    ??????????????? $("#dialog-form").dialog("open");

    ??????????? });

    ?

    ?

    ?

    ??????? $("#dialog-form").dialog({

    ??????????? autoOpen: false,

    ??????????? height: 400,

    ??????????? width: 600,

    ??????????? modal: true,

    ??????????? buttons: {

    ??????????????? "Select": function() {

    ??????????????????? var bValid = true;

    ??????????????????? if (bValid) {

    ??????????????????????? call_click();

    ??????????????????????? $(this).dialog("close");

    ??????????????????????? $(".txtMessageContent").change();

    ??????????????????? }

    ??????????????? },

    ??????????????? Cancel: function() {

    ??????????????????? $(this).dialog("close");

    ??????????????? }

    ??????????? },

    ??????????? close: function() {

    ??????????? }

    ??????? });

    ?? function call_click() {

    ??????? var i;

    ??????? var strValue;

    ??????? for (i = 0; i < $("input[name='radioName']").length; i++) {

    ??????????? if ($("input[name='radioName']")[i].checked) {

    ??????????????? strValue = $("#messageTextarea" + i.toString()).val();

    ??????????? }

    ??????? }

    ??????? $(".txtMessageContent").val(strValue);

    ?

    ?

    ?

    ?

    jQuery 元素選擇器

    jQuery 使用 CSS 選擇器來選取 HTML 元素。

    $("p") 選取 <p> 元素。

    $("p.intro") 選取所有 class="intro" 的 <p> 元素。

    $("p#demo") 選取所有 id="demo" 的 <p> 元素。

    ?

    jQuery CSS 選擇器

    jQuery CSS 選擇器可用于改變 HTML 元素的 CSS 屬性。

    下面的例子把所有 p 元素的背景顏色更改為紅色:

    $("p").css("background-color","red");

    ?

    <script type="text/javascript">

    $(document).ready(function(){

    ?//文檔加載完成后才能執(zhí)行的函數(shù)

    ? $("button").click(aa);

    });

    //

    function aa()

    {

    ?? $("p").css("background-color","blue");

    }

    </script>

    </head>

    ?

    <body>

    <h2>This is a heading</h2>

    <p>This is a paragraph.</p>

    <p>This is another paragraph.</p>

    <button type="button">Click me</button>

    </body>

    ?

    </html>

    更多的選擇器實例

    語法

    描述

    $(this)

    當前 HTML 元素

    $("p")

    所有 <p> 元素

    $("p.intro")

    所有 class="intro" 的 ? <p> 元素

    $(".intro")

    所有 class="intro" 的元素

    $("#intro")

    id="intro" 的元素

    $("ul li:first")

    每個 <ul> 的第一個 ? <li> 元素

    $("[href$='.jpg']")

    所有帶有以 ".jpg" 結(jié)尾的屬性值的 href 屬性

    $("div#intro .head")

    id="intro" 的 ? <div> 元素中的所有 class="head" 的元素

    ?

    下面是 jQuery 中事件方法的一些例子:

    Event 函數(shù)

    綁定函數(shù)至

    $(document).ready(function)

    將函數(shù)綁定到文檔的就緒事件(當文檔完成加載時)

    $(selector).click(function)

    觸發(fā)或?qū)⒑瘮?shù)綁定到被選元素的點擊事件

    $(selector).dblclick(function)

    觸發(fā)或?qū)⒑瘮?shù)綁定到被選元素的雙擊事件

    $(selector).focus(function)

    觸發(fā)或?qū)⒑瘮?shù)綁定到被選元素的獲得焦點事件

    $(selector).mouseover(function)

    觸發(fā)或?qū)⒑瘮?shù)綁定到被選元素的鼠標懸停事件

    ?

    ?

    Query 擁有可操作 HTML 元素和屬性的強大方法。

    jQuery DOM 操作

    jQuery 中非常重要的部分,就是操作 DOM 的能力。

    jQuery 提供一系列與 DOM 相關(guān)的方法,這使訪問和操作元素和屬性變得很容易。

    提示:DOM = Document Object Model(文檔對象模型)

    DOM 定義訪問 HTML 和 XML 文檔的標準:

    “W3C 文檔對象模型獨立于平臺和語言的界面,允許程序和腳本動態(tài)訪問和更新文檔的內(nèi)容、結(jié)構(gòu)以及樣式?!?/p>

    獲得內(nèi)容 - text()、html() 以及 val()

    三個簡單實用的用于 DOM 操作的 jQuery 方法:

    • text() - 設(shè)置或返回所選元素的文本內(nèi)容
    • html() - 設(shè)置或返回所選元素的內(nèi)容(包括 HTML 標記)
    • val() - 設(shè)置或返回表單字段的值

    下面的例子演示如何通過 jQuery text() 和 html() 方法來獲得內(nèi)容:

    實例

    $("#btn1").click(function(){ ? alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ ? alert("HTML: " + $("#test").html()); });

    親自試一試

    下面的例子演示如何通過 jQuery val() 方法獲得輸入字段的值:

    實例

    $("#btn1").click(function(){ ? alert("Value: " + $("#test").val()); });

    親自試一試

    ?

    轉(zhuǎn)載于:https://www.cnblogs.com/xinhua327/articles/5611581.html

    總結(jié)

    以上是生活随笔為你收集整理的MyJquery的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。