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

  • Home
  • SEARCH
  • 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 424779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:18:50+00:00 2026-05-12T19:18:50+00:00

I wrote a jQuery plugin that binds to 8 elements on a page, and

  • 0

I wrote a jQuery plugin that binds to 8 elements on a page, and I wanted to use .live() to bind the click action to a link in each element. When you click the link it should post a form using ajax. The problem is that all the links for all 8 elements submit the form for the first element on the page. When I use .click() everything works correctly. I would prefer to use .live() since I will have adding more elements dynamically.

Here is some code similar to what I’m doing:

var $container = $(this);
var $form      = $container.find('form.some_form');
var $button    = $container.find('a.some_link');

This will only submit the form for the first element:

$button
.live('click', function() {
  // some code that submits $form via ajax
});

However, this always submits the correct form:

$button
.click( function() {
  // identical code that submits $form via ajax
});

Is there something about .live() that I should know? Stumped.

  • 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-12T19:18:50+00:00Added an answer on May 12, 2026 at 7:18 pm

    From the jQuery documentation:

    Live events currently only work when
    used against a selector. For example,
    this would work: $(“li a”).live(…)
    but this would not: $(“a”,
    someElement).live(…) and neither
    would this: $(“a”).parent().live(…).

    In your case, you’re calling live() on a variable that’s the result of a find() call. That’s not a selector. You need to figure out a selector that identifies the elements you want.


    Edited to add: for anyone finding this later, the preferred approach now is to use the function on() for this. The on() function does not have the same restriction — since it operates on a jQuery object (rather than implicitly binding to the document) it can be set on a set of elements arrived at by chaining as in the original question.

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

Sidebar

Ask A Question

Stats

  • Questions 203k
  • Answers 203k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The problem is that in C++ a compile-time constant expression… May 12, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer On second reading, it looks like someone accidentally inserted an… May 12, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer I am guessing that the question is, if I am… May 12, 2026 at 8:31 pm

Related Questions

Some background: On a recent project, I tried to write a streamlined jQuery plugin
I often use links with href='#' when calling ajax resources. I noticed that IE
I wrote a quick and dirty logger as a jQuery plugin... (function($){ $.log =
I have this bit of javascript written with jQuery 1.2.5. It's contained inside the
I'm using jQuery UI's draggable and droppable libraries in a simple ASP.NET proof of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.