Trying to change the value of an attribute

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


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.





Make sure to check the browser's console for errors.
– Arvind
4 mins ago







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.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty