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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:44:20+00:00 2026-06-02T09:44:20+00:00

Basically, I tried to code the following. (note that I am a newbie in

  • 0

Basically, I tried to code the following. (note that I am a newbie in jQuery, trying to learn.)

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>

<style>
    img.box:hover { opacity: 0.4; }
</style>

<script type="text/javascript">
jQuery(document).ready(function() 
{
  $(".box").click(function(event){
      $.post("./itemdrop.php", { id: "Item:1" }, function(data){
            $('#box').append(data);
         }
      );
  });

  $("li").click(function(event){
     $(".box").append("clicked");

  })
});
</script>
</head>

<body>

<div id="box">
    <img class="box" src="./img/box.jpg" width="150" height="150">
</div>

</body>
</html>

It should work like this:

  1. User clicks on “box” image, jQuery gets values from itemdrop.php

The returned value is <li class="item">Shield of Walmar</li>

However, the jQuery doesn’t act when I click on Shield of Walmar. (I somehow have a feeling that the document ready function at top causes it.)

How can I solve this?

  • 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-02T09:44:21+00:00Added an answer on June 2, 2026 at 9:44 am

    You need to use live events/delegates. Since you are using a recent jQuery version, you want to use .on() for it:

    $('#box').on('click', 'li', function(event){
         $("#box").append("clicked");
    });
    

    I’d also suggest you to replace jQuery(document).ready(function() with jQuery(document).ready(function($) – otherwise $ inside that function only works if it’s available globally (i.e. $.noConflict wasn’t used).

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

Sidebar

Related Questions

I tried the following: Basically, it should say: If there's no cookie, get lang
I have tried and failed to get this working. Basically I am trying to
basically i have (state, state code) pairs, that are subsets of country [USA] ->
I have the following code. Basically I want to initialize a std::array of non-POD
Basically I tried evaluating the function below but keep getting the following error: WARNING
I am tyring to write some Java code that basically just plays a short
Hey, I have the following code, that gives you the effect of a mask.
I have the following code that uses Sequence objects to read data from a
Basically I'm trying to dispatch a custom made mouse click event to a text
tried to find the problem for this but nothings really working. Basically, I'm trying

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.