jQuery .click() not working?

前端 未结 4 1071
挽巷
挽巷 2021-01-14 03:57

I generate the set of buttons within html table as follows and then I want to call to function when it click.

$.each(childData, function(key, item) {
    va         


        
4条回答
  •  不知归路
    2021-01-14 04:42

    Do you want it this way? I have given code for adding an entire table.Check this out

    function generate_table() {
      // get the reference for the body
      var body = document.getElementsByTagName("body")[0];
     
      // creates a  element and a  element
      var tbl     = document.createElement("table");
      var tblBody = document.createElement("tbody");
     
      // creating all cells
      for (var i = 0; i < 2; i++) {
        // creates a table row
        var row = document.createElement("tr");
     
        for (var j = 0; j < 2; j++) {
          // Create a  in the 
    element and a text node, make the text // node the contents of the , and put the at // the end of the table row var cell = document.createElement("td"); var cellText = document.createTextNode("cell in row "+i+", column "+j); cell.appendChild(cellText); row.appendChild(cell); } // add the row to the end of the table body tblBody.appendChild(row); } // put the
    tbl.appendChild(tblBody); // appends
    into body.appendChild(tbl); // sets the border attribute of tbl to 2; tbl.setAttribute("border", "2"); }

    提交回复
    热议问题