-2
I’m learning html/css/js now, and I’m having a question that’s getting me serious. I am trying to create a button where, when pressed, hide the title (when it is showing) and make it appear again (when it is hidden). I have tried many ways, but none works. I click on the button and nothing happens. Some hint? (NOTE: I am using Jquery)
$(document).ready(function() {
if ($('h1').show()) {
(function(){
$('BUTTON').click(function(){
$('h1').hide();
})
})
} else {
(function(){
$('BUTTON').click(function(){
$('BUTTON').text('Mostrar Olá Mundo');
$('h1').show();
})
})
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1>Olá Mundo</h1>
<BUTTON>Esconder Olá Mundo</BUTTON>
<footer>
<script src="jquery.js"></script>
<script src="script.js"></script>
</footer>
</body>
</html>