toggle div tag javascript

I need a simple script to toggle a div tag on and off on an onclick link event

And please tell me where to place the script.
In a scrip section in the head of the page or at the bottom of the page

I currently have this

<style type="text/css">
        .eAddress {
            height: 60px;
            line-height: 60px;
            text-align: left;
            color: #8898AA;
            font-weight: bold;
            padding-left: 50px;
            width: 100%;
            display: none;
            clear: left;

<div id="divEditAddress" class="eAddress">TEST</div>
<div class="btAddress"><button id="btnAddress">Edit Address</button></div>
Larry Bristersr. DeveloperAsked:
Who is Participating?
Julian HansenConnect With a Mentor Commented:
Here is how you do it with one line of inline JavaScript
<div class="btAddress"><button id="btnAddress" onclick="document.getElementById('divEditAddress').style.display = (document.getElementById('divEditAddress').style.display == 'block') ? 'none' : 'block';">Edit Address</button></div> 

Open in new window

Here is how you do it with a plain JavaScript event handler
var targetDiv = document.getElementById('divEditAddress');
document.getElementById('btnAddress').addEventListener('click', function() { = ( == 'block') ? 'none' : 'block';

Open in new window

Here is how you do it with jQuery
$(function() {
	$('#btnAddress').click(function() {

Open in new window

Working sample here
Miguel OzSoftware EngineerCommented:
Use jquery toggle at scrip section  bottom of the page:
$('#yourLinkId').on('click', function(){
	var targetDiv = $('#divEditAddress').toggle();;

Open in new window

Larry Bristersr. DeveloperAuthor Commented:
Julian HansenCommented:
You are welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.