javascript - same logic across different button IDs -
javascript - same logic across different button IDs -
i have many select all
buttons within html same thing. have different ids because buttons represent different divs
have different content within them. new js , wondering how can perform same logic across many select all
buttons when 1 of them clicked?
i thought putting each select all
button in array containing ids , using
arr = [id1,id2,id3]; (var = 0; < arr.length; i++) { var k = document.getelementbyid(arr[i]); k.onclick = function() {//...logic...} }
i'm new js i'm not sure if method approach
your current code should work. create sure in array of ids, proper strings (put quotes around them). also, if plan on doing i
within click callback, please read how javascript closures work?
javascript html
Comments
Post a Comment