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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:33:34+00:00 2026-06-14T15:33:34+00:00

JSFiddle : http://jsfiddle.net/veksen/Wa4pA/4 what seems to be valid code in my eyes doesn’t work.

  • 0

JSFiddle : http://jsfiddle.net/veksen/Wa4pA/4

what seems to be valid code in my eyes doesn’t work. I used a similar method earlier in the code and it worked fine, now my variable isn’t affected. I’m grabbing text values from html and summing them up into a variable. I’m looking for a hint on why this doesn’t work, and not a full working code.

Here is the code

$(document).ready(function() {
    var char_fr = 0;
    var char_cl = 0;
    var char_lr = 0;
    var char_pr = 0;
    $(".ares .value").each( function(){
        char_cr += Number($(this.text()));
        char_fr += Number($(this.text()));
        char_lr += Number($(this.text()));
        char_pr += Number($(this.text()));
    });
    $(".cr .value").each( function() {
        char_cr += Number($(this.text()));
    });
    $(".fr .value").each( function(){
        char_fr += Number($(this.text()));
    });
    $(".lr .value").each( function(){
        char_lr += Number($(this.text()));
    });
    $(".pr .value").each( function(){
        char_pr += Number($(this.text()));
    });
    $("#mainstats .fr .stat").text(char_fr);
    $("#mainstats .cr .stat").text(char_cr);
    $("#mainstats .lr .stat").text(char_lr);
    $("#mainstats .pr .stat").text(char_pr);
});

Again I’m looking for a lead on why it doesn’t work, instead of a full code. At the same time, I’ll be having a lot more variables with matching classes, would there be a smarter way to code this, rather than having a full block for each variable? The variables and classes are similar, but it would be just fine if they were an exact match, or maybe by “prefix_”+variable.

Thanks!

  • 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-14T15:33:35+00:00Added an answer on June 14, 2026 at 3:33 pm

    Not a jQuery wrapped DOM elements, use: char_cr += Number($(this).text()); Your version is: $(this.text())

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

Sidebar

Related Questions

See this jsFiddle: http://jsfiddle.net/nathanfriend/vAcpc/9/ It seems that the preventDefault() method doesn't prevent the clicked
JsFiddle: http://jsfiddle.net/fPsK6/2/ Why visible binding doesn't work?
I have the following code that is working fine in jsfiddle - http://jsfiddle.net/darkajax/FHZBy/ I've
The jsFiddle: http://jsfiddle.net/hbrls/Snn87/12/ I have a verify code field: <input type=text id=verfy_code name=verfy_code class=required
In this jsFiddle http://jsfiddle.net/littlesandra88/RBU8K/ have I the following code function addRemove(id) { alert(1); $('#'+id).toggle(function()
http://jsfiddle.net/yTkTd/ Another function with a class works perfectly, but this one seems to be
JSFiddle : http://jsfiddle.net/veksen/7TRgE/1/ If I call the variable value from inside my function, it
Its strange :: Jsfiddle : http://jsfiddle.net/sxeCM/4/ [ Working ] Locally having the same code
This is a link to the working jsfiddle http://jsfiddle.net/akshaytyagi/SD66b/ and following is the code
JSFiddle: http://jsfiddle.net/KH8Gf/27/ Code: $(document).ready(function() { $('#expand').click(function() { var qty= $('#qty').val(); for (var counter =

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.