Why isn't my jquery script working?

Posted on 2014-08-01
Last Modified: 2014-08-01
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:

		document.getElementById('submit-page-2').disabled = true;
		alert('Pageload event has triggered');

<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?


Question by:Jonathan Greenberg
    LVL 58

    Expert Comment

    Are you including the jquery library? e.g.

    <script src="//"></script>
    LVL 24

    Accepted Solution

    What version of jquery are you using? the pageload event was deprecated in 1.4. see

    Anyway, could you just do this?

    $(function() {
      $('#submit-page-2').attr("disabled", "disabled");

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

    Author Comment

    by:Jonathan Greenberg
    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!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Suggested Solutions

    There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
    PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now