I have this .js file called by my page. The function I'm caling with my onclick is working before the button is clicked.
window.onload = function()
{
document.getElementById('clickMe').onclick = testOne();
}
function testOne()
{
var para = document.getElementsByTagName('p');
var length = para.length;
for(i=0; i<length; i++)
{
document.writeln("+");
//document.getElementById(para[i]).style.font = "Arial";
}
}
And, my HTML:
<html>
<head>
<title>Test.JS</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<div id="main">
<h1 id="title">Test.JS</h1>
<p id="first">Hello,</p>
<p id="second">Again.</p>
<p id="third">Hello.</p>
</div>
<div id="form">
<input type="text" id="txtInput" />
<input type="submit" value="Click Me" id="clickMe" />
</div>
</body>
</html>
Thank you,
Doug