Why isn't my jquery script working?

I'm trying to disable an input button on my page with a simple jquery script, but it isn't working.  Here's the script, followed by the html input button:

<script>
	$(document).on('pageload',function(){
		document.getElementById('submit-page-2').disabled = true;
		alert('Pageload event has triggered');
	});
</script>

<input type="button" name="submit-page-2" id="submit-page-2" onclick="return writePremium()" value="Next Page" />

Open in new window

I added the alert() just to see if anything at all was happening, but no luck.  Is there something that I'm doing wrong here?

Thanks!

Regards,
Jon
Jonathan GreenbergAsked:
Who is Participating?
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.

GaryCommented:
Are you including the jquery library? e.g.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
0
mankowitzCommented:
What version of jquery are you using? the pageload event was deprecated in 1.4. see http://www.w3schools.com/jquerymobile/event_pagecontainerload.asp

Anyway, could you just do this?

<script>
$(function() {
  $('#submit-page-2').attr("disabled", "disabled");
});
</script>

<input type="button" name="submit-page-2" id="submit-page-2" onclick="return writePremium()" value="Next Page" />
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
Jonathan GreenbergAuthor Commented:
Thank you, mankowitz, that did the trick!

And thanks for letting me know that the pageload event was deprecated.  I'm using jquery version 1.8.3.

Gary, thanks for the suggestion.  I did try, earlier, using that link to the jquery library, but it still didn't work.  Maybe there was a conflict between the two versions -- I didn't take the time to remove the earlier version when linking to 1.11.1.

Thanks to both of you!

Regards,
Jon
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
jQuery

From novice to tech pro — start learning today.

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.