Hopefully this is an easy question. I have a `div` that I want to toggle hidden/shown with a button

```
<div id="newpost">

```
['https://Stackoverflow.com/questions/4528085', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/547794/']
**Pure JavaScript:**

```
var button = document.getElementById('button'); // Assumes element with id='button'

button.onclick = function() {
    var div = document.getElementById('newpost');
    if (div.style.display !== 'none') {
        div.style.display = 'none';
    }
    else {
        div.style.display = 'block';
    }
};

```

[### SEE DEMO](http://jsfiddle.net/andrewwhitaker/hefGK/)

**jQuery**:

```
$("#button").click(function() { 
    // assumes element with id='button'
    $("#newpost").toggle();
});

```

[### SEE DEMO](http://jsfiddle.net/andrewwhitaker/KpFRb/)
Try with opacity

```css
div { transition: all 0.4s ease }
.hide { opacity: 0; }
```

```html
<input onclick="newpost.classList.toggle('hide')" type="button" value="toggle">

<div id="newpost">Hello</div>
```