0 Answer
Kids
A PHP Error was encountered
Severity: Notice
Message: Undefined index: userid
Filename: views/question.php
Line Number: 191
Backtrace:
File: /var/www/html/cnasolution/application/views/question.php
Line: 191
Function: _error_handler
File: /var/www/html/cnasolution/application/controllers/Questions.php
Line: 419
Function: view
File: /var/www/html/cnasolution/index.php
Line: 315
Function: require_once
Kids
Punditsdkoslkdosdkoskdo
When i use element.ClassList in for loop it store only first element class and other are undefined in JavaScript
When i use console.log to print allbu[i].classList[i] it print only first element class right and all other class name are shown undefined i made this website to change the color of button but due to this problem i am not able to complete this project if you what is solution of this problem please help me int his
var allbu = document.getElementsByTagName('button'); var buttoncopy = [] for (let i = 0; i < allbu.length; i++) { buttoncopy.push(allbu[i].classList[i]); } console.log(buttoncopy); function buchange(btc) { if (btc.value == 'red') { btcred(); } else if (btc.value == 'blue') { btcblue(); } else if (btc.value == 'green') { btcgreen(); } } function btcred() { for (let i = 0; i < allbu.length; i++) { allbu[i].classList.remove(allbu[i].classList[i]); allbu[i].classList.add('redbu'); } } function btcblue() { for (let i = 0; i < allbu.length; i++) { allbu[i].classList.remove(allbu[i].classList[i]); allbu[i].classList.add('bluebu'); } } function btcgreen() { for (let i = 0; i < allbu.length; i++) { allbu[i].classList.remove(allbu[i].classList[i]); allbu[i].classList.add('greenbu'); } }
#con { border: 1px solid black; padding: 10px; width: 65%; margin: 0 auto; display: flex; flex-direction: column; justify-content: space-around; text-align: center; } #con1 { border: 1px solid black; flex-wrap: wrap; display: flex; flex-direction: row; justify-content: space-around; padding: 5px; } button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; } select { margin-top: 20px; } .redbu { background-color: red; } .bluebu { background-color: royalblue; } .greenbu { background-color: #4CAF50; } .yellowbu { background-color: yellow; }
Button Color Change button Color