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 8051429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:18:08+00:00 2026-06-05T07:18:08+00:00

My soft.php code <!DOCTYPE html> <html> <head><style> </style> <script src=jquery.js></script> <script> $(function(){ $(button).on(click,function(){alert(f);}); $(div).on(click,function(){

  • 0

My soft.php code

<!DOCTYPE html>
<html>
<head><style>
</style>
<script src="jquery.js"></script>
<script>
$(function(){
$("button").on("click",function(){alert("f");});
$("div").on("click",function(){
$("span").load("check.php");
});

});</script></head><body>
<div>Click</div>
<button>eaf</button><span></span>
</body></html>

And check.php code

<body>
<button>Hello</button>
</body>

I want to alert f on clicking on button which is loaded via ajax which was working fine with .live().
But someone told me that .on() can be used in place of live but .on() is not working here.Suggest Solution

  • 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-06-05T07:18:09+00:00Added an answer on June 5, 2026 at 7:18 am
    $('body').on("click", "button", function(){
        alert("f");
    });
    

    As your button added to DOM after page load you need to use delegate event.

    It would be better to use something other selector instead of body.

    You can use multiple selector like follwoing:

    $('body').on("click", "button, div", function(){
        alert("f");
    });
    

    Read about .on()

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

Sidebar

Related Questions

Im using the Google pagerank checking script found here: http://www.off-soft.net/en/develop/php/prcheck.html I've noticed however that
This is my code: <?php $url = http://www.uhasselt.be/collegeroosters/2009_2010_298_5_10.html; $headers = get_headers($url, 1); print_r($headers); $contloc
I am setting up Code Igniter. My public html folder is a soft link
This is kind of a soft question, but in the following code, there's a
I'm trying to use LISTSERV's API in PHP. L-Soft calls this TCPGUI, and essentially,
I am developing soft keyboard and I added a toggle button similar to the
I have a game site developed using flash and php. The php code contains
I wrote a regex in Rad Soft to pull out a div tag from
I'm wondering if there are any existing (ideally well documented) PHP or Javascript/jQuery libraries/plugins
I currently use soft tabs (i.e. spaces) for indenting my Ruby code, if I

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.