简体   繁体   English

我似乎无法在我的javascript中正确嵌入一些html

[英]I can't seem to embed some of my html in my javascript correctly

I have a javascript function where I'm embedding html. 我在其中嵌入html的javascript函数中。 I have a variable that I'm trying to call a toString method on. 我有一个变量,我正在尝试调用toString方法。 However, my page doesn't like the way I have my quotes I think. 但是,我的页面不喜欢我使用引号的方式。 This is what I have: 这就是我所拥有的:

function (item) {
    '<h3>' + item.StartDate.ToString("MM/dd/yyyy") + '</h3>'
}

I think that it probably wants to look like: 我认为它可能看起来像:

function printMyItem(item) {
    return '<h3>' + item.StartDate.toString("MM/dd/yyyy") + '</h3>';
}

document.write(printMyItem());

Also the syntax is toString instead of ToString . 而且语法是toString而不是ToString

Something like that? 这样的事吗?

您的引号很好,但它的toString不是ToString

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM