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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:35:15+00:00 2026-05-29T05:35:15+00:00

My Simple HTML Structure: <html> <body> <p id=5> My Text Qoted Here – <span

  • 0

My Simple HTML Structure:

<html>
    <body>
<p id="5">
    My Text Qoted Here - 
    <span class="author">Author </span>
          <br>
          <span class="uptext">20</span>
          <img class="im" class="upimg" 
          src="http://bgathinktank.files.wordpress.com/2011/01/vote-button.jpg" />
          <img class="im" class="downimg"
          src="http://2.bp.blogspot.com/_XeuZ1yDnv4Q/TSUkAT6T1dI/AAAAAAAADR8/nPHP4JvVxy8/s1600/vote.jpg" />
          <span class="downtext">5</span>
          </p>
</body>
</html>       

as can be seen there are two images, and i want to change the count of the image based on which image is clicked.

i write the following jquery code for it:

$(function() {
 $(".upimg").click(function(e) {
        e.preventDefault();
        alert("here1");
        curr_val = $(this).closest(".uptext").text();
        nos = parseInt(curr_val, 10) + 1;
        $(this).closest(".uptext").text(nos);
    });

    $(".downimg").click(function(e) {
        e.preventDefault();
        alert("here2");
        curr_val = $(this).closest(".downtext").text();
        nos = parseInt(curr_val, 10) + 1;
        $(this).closest(".downtext").text(nos);
    });

});

But it does not seem to respond.
You can find the fiddle here

  • 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-29T05:35:16+00:00Added an answer on May 29, 2026 at 5:35 am

    Your <img> tags have two class attributes:

    <img class="im" class="upimg"
    

    Try changing that to

    <img class="im upimg"
    

    Also, the closest() method returns the closest parent element, not an adjacent sibling, so to find the correct uptext element, you need to use:

    $(this).prev().text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple HTML structure ( jsfiddle ): <li> <div class=buttons> <a href=done><img
I have some content sliding here. http://www.smallsharptools.com/downloads/jQuery/Slider/slider.html The HTML structure is simple. There is
A simple HTML form: <form enctype=application/x-www-form-urlencoded method=post action=/view/album/id/4><ol> <li class=no-padding><div class=element> <input type=hidden name=media
I have a simple html block like: <span id=replies>8</span> Using jquery I'm trying to
Heres my simple html source <html> <head> <title> Dec2Bin </title> <script type=text/javascript> function app()
<html> <head> </head> <body> <div> <a href=http://www.google.com> <span>title<br></span> <span>description<br></span> <span>some url</span> </a> </div> </body>
I have this simple html structure: <div id=mainbody> <div id=main> ... </div> <div id=left>
I have this simple HTML structure: <ul> <li> One <p> Foo is a fool.
I have a fairly simple dynamic html structure of a table that contains links
I'm trying to print a simple HTML tree structure, consisting of ul and li

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.