+ 1

Buttons in JavaScript,jQuery

for(var k=0;k<42;k++){ b.eq(k).click(function(){ for(var i=0;i<6;i++){ for(var j=0;j<7;j++){ if(("r"+i+"c"+j)===this.id){ temp = "r"+0+"c"+j var t = $(temp) t.css("background-color","blue") } } } }) } I don't know why t is not working.

16th Sep 2019, 7:06 PM
harshit
harshit - avatar
3 Réponses
+ 2
What is your main target about button if you want to create multiple buttons try this https://code.sololearn.com/WlkGBf8Z7fLC/?ref=app If Not then re send your Question
16th Sep 2019, 7:41 PM
Qudusayo
Qudusayo - avatar
+ 2
Oh, just give all buttons same class or name and then bind click on that class. Like this $(".buttons").on("click", function (){ //Your logic here }) If that is a table, where buttons are? If yes, you can use $(this).closest("td") or ...closest("tr") and get indexes from them And if you are using jQuery then don't ever go so complicated, because jQuery is made for simplicity
16th Sep 2019, 8:57 PM
Dejan Dozet
Dejan Dozet - avatar
0
Qudusayo I have created 42(6×7) buttons with different ids. I wnat to check which specific button was clicked to change its colour (actually it's column's lowest cell colour).
16th Sep 2019, 7:58 PM
harshit
harshit - avatar