This article mainly introduces the method of adding columns dynamically in JavaScript. The example analyzes the skills of using javascript to operate table forms, which has some reference value, for more information about how to dynamically add columns in JavaScript, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
/***** Dynamically add the table column * @ param result */function addRow (resultJson) {/* var temp = []; temp = $. grep (arr, function (val, key) {if (val. indexOf ('C ')! =-1) return true; // if the [invert] parameter is not set or is false, $. grep only collects the array elements returned by the callback function. // otherwise, the [invert] parameter is true, $. the grep collection callback function returns an array element of false}, false); console. dir (temp); */if (resultJson! = "") {Var cv_arr = new Array (); var date_arr = new Array (); // parse the data source and parse it into the date and result $ that can be recognized by the program. each (resultJson, function (index, val) {if (val ['Parser _ schedule']! = Null) {cv_arr.push (val ['Parser _ schedule']); var temp_data = val ['Parser _ schedule']. split (","); for (I = 0; I
"+ Date_arr [I] +""); $ (" # Mytable tbody tr "). append ("-");} Var rowNum_arr = new Array (); // obtain the total number of rows for (I = 0; I <$ (" # mytable "). find ("tr "). length; I ++) {// obtain the value of the third column in each row. The first two columns of the table are hidden, the third column starts to judge whether there is data var str =$ ("# mytable tbody "). find ("tr "). eq (I); var std = str. find ("td "). eq (2); // record when no value exists and obtain the row number if ($. trim (std. text ()). length <1) {rowNum_arr.push (I);} else {// optional (std;.html ("") ;}// set TD information for (I = 0; I
I hope this article will help you design javascript programs.