Jump to content

Js function to stop displaying an element

Hi everybody! So i have this element... Let's cal it "arrow", now i need "arrow" to not be displayed once we press that button. I made the function, but it doesn't work, what are the flaws?

My useless code:

function arrowOff() {
                    var m = document.getElementByClassName("arrow");
                    m.style.display = "none";
                        }

 

Link to comment
https://linustechtips.com/topic/1095157-js-function-to-stop-displaying-an-element/
Share on other sites

Link to post
Share on other sites

4 minutes ago, SafyreLyons-5LT said:

function arrowOff() {
 var m = document.getElementByClassName("arrow");
 m.style = "display: none";
}

Do something like this it works for me

Doesn't for me ?. But vs tells me it's declared, but the value is never read.

Link to post
Share on other sites

1 minute ago, SafyreLyons-5LT said:

function arrowOff() {
	document.getElementByClassName("arrow").style.display = "none";
}

This works I tested it

It has to! I think it's more of a Visual Studio problem, like I said it tells me "(JS) 'arrowOff' is declared but its value is never read."

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×