第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)我使用 jquery 附加到 HTML 表時,我無法觸發(fā)表行單擊事件

當(dāng)我使用 jquery 附加到 HTML 表時,我無法觸發(fā)表行單擊事件

動漫人物 2023-09-11 15:15:45
我正在使用 asp.net mvc。我正在嘗試使用 jquery 附加到 HTML 表。我從 getJSON 調(diào)用獲取行并將它們附加到表中。行已附加,但由于某種原因,添加的行不會觸發(fā)單擊事件。我認(rèn)為這可能與時間或其他原因有關(guān),但我不確定。控制器using System;using System.Web;using System.Web.Mvc;namespace Test{    public class HomeController : Controller    {        public ActionResult Index()        {            return View();        }        public ActionResult Test(string x)        {            string strJson = "[{\"name\":\"tom\",\"number\":\"111\"},{\"name\":\"bill\",\"number\":\"222\"}]";            return Json(strJson, JsonRequestBehavior.AllowGet);        }    }}看法@{    Layout = null;}<style>    td {        border: 2px solid black;    }</style><br /><br /><table id="table1">    <tr>        <td>            name        </td>        <td>            number        </td>    </tr></table><br /><br /><button id="button1" type="button">append rows</button><script src="~/Scripts/jquery-3.4.1.js"></script><script>    //table click event    $(document).ready(function () {        $("#table1 tr").click(function () {            alert("table row clicked");        });    });    //button click event    $(document).ready(function () {        $("#button1").click(function () {            $.getJSON('@Url.Action("Test")', { x: "1" }, function (y) {                y = $.parseJSON(y);                $.each(y, function (i, item) {                    $('#table1').append('<tr><td>' + item.name + '</td><td>' + item.number + '</td></tr>');                });            });        });    });</script>
查看完整描述

1 回答

?
繁星淼淼

TA貢獻(xiàn)1775條經(jīng)驗(yàn) 獲得超11個贊

該事件未觸發(fā),因?yàn)樵撔惺窃诟郊邮录幚沓绦蚝筇砑拥?。使用?/p>

$(document).on("click", "#table1 tr", function (){}


查看完整回答
反對 回復(fù) 2023-09-11
  • 1 回答
  • 0 關(guān)注
  • 98 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號