2017-10-21 42 views
1

在這裏,我想綁定標識值,其點擊Event.When我點擊編輯鏈接的命中Hello功能如何寫Jquery的單擊事件表中的

$('#Btn2').click(function() { 
     $.ajax({ 
      url: "http://localhost:44509/api/Stored/GetEmployee", 
      type: 'GET', 
      dataType: 'json', 
      success: function (data) { 
       var $table = $('<table/>').addClass('table table-responsive table-striped table-bordered'); 
       var $header = $('<thead/>').html('<tr><th>EmpId</th<th>Action</th></tr>'); 
       $table.append($header); 
       $.each(data, function (i, value) { 
        var $row = $('<tr/>'); 
        $row.append($('<td/>').html(value.Emp_Id));    
        $row.append($('<td/>').html("<a href='http://localhost:44509/api/Stored/EditEmp' click='Hello()'" + value.Emp_Id + ">Edited</a>")) 
        $table.append($row); 
       }); 
       $('#Div1').html($table); 
      } 
     }) 
    }) 

    $('#Hello').click(function() { 
     alert(); 
    }) 

回答

1

meybe這樣的:

$('#Btn2').click(function() { 
     $.ajax({ 
      url: "http://localhost:44509/api/Stored/GetEmployee", 
      type: 'GET', 
      dataType: 'json', 
      success: function (data) { 
       var $table = $('<table/>').addClass('table table-responsive table-striped table-bordered'); 
       var $header = $('<thead/>').html('<tr><th>EmpId</th<th>Action</th></tr>'); 
       $table.append($header); 
       $.each(data, function (i, value) { 
        var $row = $('<tr/>'); 
        $row.append($('<td/>').html(value.Emp_Id));    
        $row.append($('<td/>').html("<a href='http://localhost:44509/api/Stored/EditEmp' onClick='Hello(\'"+value.Emp_Id+"\');'>Edited</a>")) 
        $table.append($row); 
       }); 
       $('#Div1').html($table); 
      } 
     }) 
    }) 

    function Hello (_in) { 
     alert(_in); 
    })