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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:35:10+00:00 2026-05-22T22:35:10+00:00

in below code if i replace temp in $(this).text(temp); with something it works and

  • 0

in below code if i replace temp in $(this).text(temp); with "something" it works and change span text, but when i use a string.format it doesn’t work.

jquery code:

  var x = $("span.resource");           
  x.each(function () {            
       if ($(this).attr('id') = "l1") {
           var temp = String.Format("{0}/{1}", variable1,variable2);
           $(this).text(temp);
       });
  • 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-22T22:35:11+00:00Added an answer on May 22, 2026 at 10:35 pm

    If you look at MDC there’s no method named Format for the String object. My guess is that you are confusing languages (JavaScript and C#), which is quite common for multi-language developers.

    However, everything’s not lost. You can easily recreate an equivalent method in JavaScript by adding to the prototype of the String object. Credits go to gpvos, Josh Stodola, infinity and Julian Jelfs who contributed to these solutions to a similar problem.

    String.prototype.format = function(){
      var args = arguments;
      return this.replace(/\{(\d+)\}/g, function (m, n) { return args[n]; });
    };
    

    With a little tweaking it should work like this:

    $("span.resource").each(function(){
        if (this.id == "l1") {
            var $this = $(this),
                newText = $this.text().format(var1, var2);
            $this.text(newText);
        }
    });
    

    Blair Mitchelmore have a similar implementation on his blog, but with some extra features and added functionality. You might want to check that out as well!

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

Sidebar

Related Questions

Below code is working properly now. But if I replace 'text.txt' with ' http://google.com
I am using the below code to replace some text which is working fine.
I'm using the simple code below to replace a textbox ( <input type=text />
In the below code snippet can i replace char * to const char *
In the below code sample, what does {0:X2} mean? This is from the reflection
For example I have code below string txt=I have strings like West, and West;
Hi I have this code below and am looking for a prettier/faster way to
I'm using the code below to add/edit pdf's yet it doesn't seem to be
I am trying to understand this one line of code below: str_replace('../', '', $route);
I am using below code to replace , with \n\t ss.replace(',','\n\t') and i want

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.