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;
        }
    </style>

<div id="divEditAddress" class="eAddress">TEST</div>
<div class="btAddress"><button id="btnAddress">Edit Address</button></div>
Larry Bristersr. DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
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() {
	targetDiv.style.display = (targetDiv.style.display == 'block') ? 'none' : 'block';
})

Open in new window

Here is how you do it with jQuery
<script>
$(function() {
	$('#btnAddress').click(function() {
		$('#divEditAddress').toggle();
	});
});
</script>

Open in new window


Working sample here
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Miguel OzSoftware EngineerCommented:
Use jquery toggle at scrip section  bottom of the page:
http://api.jquery.com/toggle/
<script>
$('#yourLinkId').on('click', function(){
	var targetDiv = $('#divEditAddress').toggle();;
});
</script>

Open in new window

0
Larry Bristersr. DeveloperAuthor Commented:
Thanks
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.