Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 在动态表的超链接列上单击所需的函数_Jquery_Html_Hyperlink - Fatal编程技术网

Jquery 在动态表的超链接列上单击所需的函数

Jquery 在动态表的超链接列上单击所需的函数,jquery,html,hyperlink,Jquery,Html,Hyperlink,我有一个动态表。它的第三列显示超链接记录。点击超链接。它应该重定向到新窗口 这是我的职责: function getErrorStatusList() { var serve = JSON.stringify({ program: $("#proselct option:selected").text() }); $.ajax({ type: "POST", url: "UFZillaErrorStatus.aspx/GetErrorStatusL

我有一个动态表。它的第三列显示超链接记录。点击超链接。它应该重定向到新窗口

这是我的职责:

function getErrorStatusList() {
    var serve = JSON.stringify({ program: $("#proselct option:selected").text() });
    $.ajax({
        type: "POST",
        url: "UFZillaErrorStatus.aspx/GetErrorStatusList",
        data: serve,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            $("#result").empty();
            obj = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
            var output = "<table id='tblResult'><tr><th>Serial No.</th><th>UFZillaID</th><th>MZillaID</th><th>Status</th></tr>";

            for (var x = 0; x < obj.length; x++) {
                output += "<tr><td>" + (x + 1) + "</td><td>" + obj[x].IssueID + "</td><td>" + obj[x].EMID + "</td><td>" + obj[x].EMStatus + "</td></tr>";
            }
            output += "</table>";
            $("#result").append(output);

        },
        error: function () { alert("Server Error!!"); }

    });
但这不符合


任何建议都会有帮助

在动态元素的情况下使用ID可以创建重复的元素

试试这个

$(document).on('click','td:eq(2) a',function(event){
    event.preventDefault();
    //your function goes here.
})
  • 对于第三列-使用
    td:eq(2)
    。并为超链接添加
    a

  • 对于动态添加的元素,您需要使用-

    • 你可以试试这个

       <script type="text/javascript">
      jQuery(document).ready(function() {
            jQuery("#EMID").click(function () {
      
              //your function.
      
              return false;
            });
            jQuery("#EMID").trigger("click");
      });
      </script>
      
      
      jQuery(文档).ready(函数(){
      jQuery(“#EMID”)。单击(函数(){
      //你的功能。
      返回false;
      });
      jQuery(“EMID”)。触发器(“单击”);
      });
      
      1.如果您的“EMID”始终是超链接,请将for循环更改为:

      for (var x = 0; x < obj.length; x++) {
          output += '<tr><td>' + (x + 1) + '</td><td>' + obj[x].IssueID + '</td><td><a class="fun-link" href="#">' + obj[x].EMID + '</a></td><td>' + obj[x].EMStatus + '</td></tr>';
      }
      

      使用事件授权我已编辑了您的标题。请不要在问题标题中包含关于所用语言的信息,除非没有它就没有意义。标签就是为了这个目的。还有,如果共识是“不,他们不应该
      for (var x = 0; x < obj.length; x++) {
          output += '<tr><td>' + (x + 1) + '</td><td>' + obj[x].IssueID + '</td><td><a class="fun-link" href="#">' + obj[x].EMID + '</a></td><td>' + obj[x].EMStatus + '</td></tr>';
      }
      
      $(document).on('click', '.fun-link', function(event) {
          event.preventDefault();
      /* Act on the event */
      });