阅读背景:

如何使用javascript访问按钮中的数据点击网格中的行(由jquery动态绑定)?

来源:互联网 
function updateGrid(data) { // appending the retrieved data(user details) to the grid
        var i = 0;
        var content;
        $("#GridView1").html('');
        $("#GridView1").append("<tr><th>" + "Name" + "</th><th>" + "Gender" + "</th><th>" + "Date of Birth" + "</th><th>" + "Role" + "</th><th>" + "Password" + "</th><th>" + "Email" + "</th><th>" + "Edit" + "</th></tr>");
        while (data[i] != null)
        {
            $("#GridView1").append("<tr><td>" + data[i].name + "</td><td>" + data[i].gender + "</td><td>" + data[i].dob + "</td><td>" + data[i].role + "</td><td>" + data[i].password + "</td><td>" + data[i].email + "</td><td>" + "<button id=btnEdit  onclick='test()'>Edit</button>" + "</td></tr>");// HERE I M DYNAMICALLY CREATING A BUTTON IN THE LAST. WHEN I CLICK IT IT CALLS TEST().HOW CAN I SEND THE DATA IN THIS ROW TO THAT TEST() FUNCTION IN ORDER TO ACCES THEM
            i++;
        }
    }
    function test() {

        alert('edit button is clicked');
        // I NEED TO ACCESS THE ROW'S DATA WHERE THIS EDIT BUTTON IS CLICKED.
    }
function updateGrid(data) { // appending the re



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: