Skip to content

Instantly share code, notes, and snippets.

@ngnam
Created December 15, 2019 16:51
Show Gist options
  • Save ngnam/9a50318e22d9f42efd74331bcff1eb02 to your computer and use it in GitHub Desktop.
Save ngnam/9a50318e22d9f42efd74331bcff1eb02 to your computer and use it in GitHub Desktop.
checkbox click.js
(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