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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:42:06+00:00 2026-06-08T03:42:06+00:00

Maybe isn’t good title for the question but my problem is exactly this. I

  • 0

Maybe isn’t good title for the question but my problem is exactly this.
I have several DIV tags on the page and all of them start as #result and continue with number <div id="result22">, <div id="result33"> etc. Now I’m find some nice jQuery things to do and it works as expected but the only problem is how to add known number to the #result
here is the code:

<script type="text/javascript">
   $(document).ready(function() {
     $('.like').bind('click', function () {
       $.get("/sng_like/"+this.id+"/", function(data) {
         $('#result')[0].innerHTML=data;
     });
   });
 });
</script>

I want that value of this.id to be a part of the #result to get #result22 for example.
My JS knowledge is limited and I was already try $('#result'+this.id)[0].innerHTML=data; but it wont work.

Thanks,
G

  • 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-08T03:42:07+00:00Added an answer on June 8, 2026 at 3:42 am
    $(document).ready(function() {
         $('.like').bind('click', function () {
           var item=$(this);
           $.get("/sng_like/"+item.attr("id")+"/", function(data) {
             $('#result'+item.attr("id")).html(data);
         });
       });
    });
    

    As of jQuery 1.7, the .on() method is the preferred method for attaching event handlers to a document. So you may consider using that.

    If you are using 1.7+ version, your code can be rewritten to use on function like this

    $(function(){
       $(document).on("click",".like",function(){
           var item=$(this);           
           $.get("/sng_like/"+item.attr("id")+"/", function(data) {
              $('#result'+item.attr("id")).html(data);
           });
       });
    });
    

    $(function() is a short form of $(document).ready(function()

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

Sidebar

Related Questions

Maybe this isn't a new question; but unfortunately I'm unable to solve my problem.
Maybe this isn't even a valid question, so any help would be good.
Maybe this isn't a programming question per se, but it relates to the coding
Maybe this isn't possible due to Security implications... I have a Deployment Package created
Maybe this isn't really feasible. But basically, I've been developing a snippet-sharing website and
Hopefully this question isn't as subjective as I think it may be. I have
Maybe I've been staring at this problem for too long, maybe there isn't an
Maybe this isn't possible, I've never seen it myself, but thought I'd ask. If
I have a MEMORY table in MySQL for a live chat (maybe this isn't
Maybe this is an obvious question, maybe it isn't. Imagine a GUI control application

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.