字符串文本跨度,如果我在$(this).text(temp);
与"something"
它的工作原理更换temp
,改变span
文本,但是当我使用一个string.format
它不工作。替换在下面的代码jQuery的
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);
});
'variable1'和'variable2'从哪里来? – mekwall 2011-06-06 09:09:36
您可能会发现[此链接](http://stackoverflow.com/questions/610406/javascript-printf-string-format)有用,也可能发现使用'id = l1'找到元素效率更高'$('#l1')' – jaime 2011-06-06 09:12:28
另外,如果你看一下[MDC](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String),那么没有名为'Format'的方法'String'对象。你可能会混淆语言吗? ;) – mekwall 2011-06-06 09:14:48