Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Disappearing act

Hello, what’s wrong with my code? Any help will be very appreaciated

script>
var showButton = ("#showButton"); // Create the variable 'hideButton' to store #hideButton var hideButton = ("#hideButton");
var image = $("#image");
function showElement() {
image.show();
}
function hideElement() {
// Use the “hide()” function on the image variable:
image.hide();
}
showButton.on(“click”, showButton);
// Add an event listener to the hideButton variable.
// It should perform hideElement when a “click” occurs:
hideButton.on(“click”, hideButton)

1 Like

Howdy and welcome to the forum!

Please post your code formatted properly. This link will show you how: [Essentials] How To Post/Format Your Code Correctly

That being said, notice the difference in these three lines of code (not the comment)? Only one of them is correct:

    var showButton = ("#showButton"); 
    // Create the variable 'hideButton' to store #hideButton 
    var hideButton = ("#hideButton");
    var image = $("#image");
2 Likes