我能';我似乎没有在javascript中正确嵌入一些html
我有一个javascript函数,在其中嵌入html。我有一个变量,我正试图调用一个toString方法。然而,我的页面不喜欢我引用的方式。这就是我所拥有的:我能';我似乎没有在javascript中正确嵌入一些html,javascript,html,Javascript,Html,我有一个javascript函数,在其中嵌入html。我有一个变量,我正试图调用一个toString方法。然而,我的页面不喜欢我引用的方式。这就是我所拥有的: function (item) { '<h3>' + item.StartDate.ToString("MM/dd/yyyy") + '</h3>' } 功能(项目){ ''+项目开始日期至字符串(“MM/dd/yyyy”)+'' } 您的报价很好,但它的toString不是toString我认为它可能希
function (item) {
'<h3>' + item.StartDate.ToString("MM/dd/yyyy") + '</h3>'
}
功能(项目){
''+项目开始日期至字符串(“MM/dd/yyyy”)+''
}
您的报价很好,但它的toString
不是toString
我认为它可能希望看起来像:
function printMyItem(item) {
return '<h3>' + item.StartDate.toString("MM/dd/yyyy") + '</h3>';
}
document.write(printMyItem());
函数printMyItem(项目){
返回“”+item.StartDate.toString(“MM/dd/yyyy”)+“”;
}
document.write(printMyItem());
此外,语法是toString
,而不是toString
类似这样的?它是
toString()
带小写“t”。你有什么问题?@Pointy:而且它不带参数。这看起来像C代码。也可以使用变量,然后嵌入变量@SLaks可能是DateJS?猜猜这里…是的,我不确定“StartDate”属性是否不是一个具有函数“ToString(formatString)”的对象