Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

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
0
Jonathan Greenberg
Asked:
Jonathan Greenberg
1 Solution
 
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
 
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now