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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:46:15+00:00 2026-06-10T22:46:15+00:00

Script: var degress = GiveDegrees(); $(function () { //alert(GiveDegrees()); //output: 89,91,87,90,91 }); function GiveDegrees()

  • 0

Script:

var degress = GiveDegrees();

$(function () {
    //alert(GiveDegrees());  //output: 89,91,87,90,91
});

function GiveDegrees() {
    var divs = $('p.wx-temp');
    var degrees = new Array();

    $.each(divs, function (i, j) {
        degrees.push(stringToNum($(this).text()));
    });

    return degrees;
}

function stringToNum(str) {
    return str.match(/\d+/g);
}

I have this :

$("p.wx-temp").each(degress, function (index) {
    $(this).append(degress[index], "<sup>°C</sup>");

    alert("I works");
});

But It does not work. when I write like this:

$("p.wx-temp").each(function (index) {
    $(this).append("<sup>°C</sup>");

    alert("I works");
});

It works. Is there no overload method for .each() function .each(data, function (index)) ?

degrees array is integer array that include five int as 89,91,87,90,91. How can I use .each function to add array values to each p element.

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-10T22:46:16+00:00Added an answer on June 10, 2026 at 10:46 pm

    Why would you need to bring degress into the each at all? It’s already available, using closures:

    $("p.wx-temp").each(function(index) {
        $(this).append(degrees[index], "<sup>°C</sup>");
        alert("I works");
    });
    

    OR

    var $elems = $("p.wx-temp");
    $.each(degrees, function(i, val) {
        $elems.eq(i).append(val, '<sup>°C</sup>');
    });
    

    If the elements length matches the array length, it should make no difference wich one you loop, but the first one is probably faster (although using a native array loop would be fastest).

    Note that you are spelling degrees and degress differently in the two sections.

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

Sidebar

Related Questions

In my background script: var collection = Backbone.Collection.extend({}); chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { sendResponse(new collection());
Please see the following script: var x = function(param){ this.data=param; this.y = function(){ alert(this.data)
Here's my script: var Ajax = { init: function(){ try{ this.xmlHttp = new XMLHttpRequest();
I have this little script: var moolang = new Class({ initialize: function(element) { this.el
I have an array that was populated by this script : var imgs =
Bear with me, I've new to Javascript. Here's my parent script: var title =
with this script var d = new Date(2010, 10, 30); var e = new
I have the following script: var $j = jQuery.noConflict(); $j(window).load(function () { $j('#loading').fadeOut('fast', function
Here is the script: var currentCat = all; $(document).ready(function(){ $(.categoryItem).click(function(event){ $(#browseBookArea).fadeToggle(100); currentCat = $(this).attr(id);
I'm using this script: var canvas = new fabric.Canvas('game_canvas', { selection: false }); fabric.Image.fromURL('images/bg.jpg',

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.