Trying to change the value of an attribute
Trying to change the value of an attribute
var btnl=document.getElementById("btnl");
var btns=document.getElementById("btns");
var log=document.querySelector("log");
var sub=document.querySelector("sub");
var hide=document.querySelector("hide");
//when the user clicks the button the class changes
btnl.addEventListener('click', function(){
log.setAttribute("class","olog");
});
btns.addEventListener('click', function(){
sub.setAttribute("class","osub");
});
Whenever I run the page the nothing happens. Right now I've no clue where I made my mistake.
It would be neat if you could include all of the side effects you expected as a result of clicking that button. e.g. Which element is being clicked? What type of element is it? What styles are assigned to that the classes
olog
and osub
and do they differ from the default styles? All of these clues would be helpful to answerers. Feel free to edit your question to include them.– ctt
3 mins ago
olog
osub
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Make sure to check the browser's console for errors.
– Arvind
4 mins ago