How to Show hide toggle display a DIV using javascript?

If you want to show/hide a div, you are on the right place here is an example


<input type=button value="Please click here" onClick="javascript:toggle()">
<script>
function toggle(){
	var div1 = document.getElementById('welcomeform')
	if (div1.style.display == 'none') {
		div1.style.display = 'block'
	} else {
		div1.style.display = 'none'
	}
}
</script>
<div id="welcomeform" style="display:none;">Welcome :-)</div>