tratando de hacer una secuencia de comandos de eliminación automática de filas sin eliminar algunas líneas específicas con orden de venta # SO10100
let delete_nums = ["#SO202771", "#SO202772", "#SO202773"]; function getRowsToDelete() { // Initialize an array that's going to contain all the rows to be deleted let delete_rows = []; // Get the element that contains all the rows const ordenDeVenta = document.getElementsByClassName("uir-machine-row"); // Loop through all these rows Array.from(ordenDeVenta).forEach(row => { // Find the cell that contains the order no. const cellWithNum = row.children[x]; // Go through each order no that has to be deleted delete_nums.forEach(num => { // If it's in the cell if (cellWithNum.textContent.contains(num)) { // Add the row to the array delete_rows.push(row); } }) }) // Return the array with rows to be deleted return delete_rows; }Si desea hacer clic automáticamente en el elemento (como dice su título), puede usar:
row.click();Deberías tener un evento en la fila. De lo contrario, si está en un botón, busque el botón en sí.
Si desea eliminar una línea, puede usar element.remove() que hará el trabajo:
function del(id) { document.getElementById("row-" + id).remove(); } <table> <tr> <th>A</th> <th>B</th> <th>C</th> </tr> <tr id="row-1" onclick="del(1)"> <td>1</td> <td>1</td> <td>1</td> </tr> <tr id="row-2" onclick="del(2)"> <td>2</td> <td>2</td> <td>2</td> </tr> </table> Aquí, todo se simplifica. En su caso, en lugar de usar getElementById , está usando el elemento secundario de getElementsByClassName .