Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:42:02+00:00 2026-05-23T18:42:02+00:00

On JQuerys’s page (http://api.jquery.com/submit/) I am trying out one of their examples. It’s pure

  • 0

On JQuerys’s page (http://api.jquery.com/submit/) I am trying out one of their examples. It’s pure copy paste but (except, html, body, etc.) Still it doesn’t work. What is the problem:

<body>
<html>
<head>
<script>

$('#target').submit(function() {
  alert('Handler for .submit() called.');
  return false;
});

</script>

</head>

<form id="target" action="get_input_values.html">
  <input type="text" value="Hello there" />
  <input type="submit" value="Go" />
</form>
<div id="other">
  Trigger the handler
</div>

</body>
</html>

I just want to have a function that can be triggered when I submit a form. Next step I will need to get the values from the input fields.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:42:02+00:00Added an answer on May 23, 2026 at 6:42 pm

    You’ll want to attach the submit event to the form once the form has loaded on the page.

    To do this you can wrap the whole thing in a $(document).ready():

    $(document).ready(function(){
       $('#target').submit(function() {
          alert('Handler for .submit() called.');
          return false;
       });
    });
    

    This is basically saying that once the document has finished loading, go and find the form and attach a submit event to it. Trying to do this the way you did it runs the risk that the form on the page won’t have loaded by the time your Javascript tried to find it.

    Here’s a working example of your code: http://jsfiddle.net/MmMa8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery: <script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js/> $(document).ready({ $(.title).click(function(){ var descID = $(this).attr(id); var newID = #+descID+d;
I have an issue using jquerys selectors when it comes to a page I
I'm using Greasemonkey and JQuerys #css method to add css styles to a page.
I'm trying to do a simple example using jQuerys fadeTo method. It works as
Jquery/programming newb here. I'm trying to dynamically assign a height to a ul to
I've been trying to figure this out over several questions here on SO, finding
I am reading a book about Javascript and jQuery and using one of the
Im trying to use Jquerys.tabs control. I dont see the logic. If i use
I'm using jquerys autocomplete widget but I'm having a few issues trying to style
Jquery has a great language construct that looks like this: $(document).ready(function() { $(a).click(function() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.