字符串文本跨度,如果我在$(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