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);
});
If you look at MDC there’s no method named
Formatfor theStringobject. 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
Stringobject. Credits go to gpvos, Josh Stodola, infinity and Julian Jelfs who contributed to these solutions to a similar problem.With a little tweaking it should work like this:
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!