Created
December 15, 2019 16:51
-
-
Save ngnam/9a50318e22d9f42efd74331bcff1eb02 to your computer and use it in GitHub Desktop.
checkbox click.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function test() { | |
// một số hàm truy xuất DOM trên browserm get element, finder, children, parent,... | |
var htmlCollection = document.getElementsByClassName('questions-list' ; | |
var arrCollection = []; | |
// tìm hiểu apply funciton trong javascript la gì. | |
[].push.apply(arrCollection, htmlCollection); | |
// foreach là gì | |
arrCollection.forEach(function(item) { | |
if (!item) { | |
return; | |
} | |
var elInputTrHtmls = item.getElementsByTagName('tbody' [0].getElementsByTagName('tr' ; | |
var elInputTr = []; | |
[].push.apply(elInputTr, elInputTrHtmls); | |
elInputTr.forEach(function(trow) { | |
// cột chứa input checkbox | |
// theo thứ tự index: từ 0, 1, 2, 3, 4 ok em hiểu cái này | |
var input = trow.getElementsByTagName('td' [3].getElementsByTagName('input' [0]; | |
console.log(input); | |
if (input) { | |
setTimeout(function() { | |
input.click(); | |
}, 200) | |
}}); | |
})})(); | |
// anonymousfunciton | |
(funtion nameFunction(){ | |
// code here// viet như này gọi la anonymousfunction, define xong call luôn | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment