>>\');" />
开发者

Using Jquery append() to build html and pass null javascript values

Here is my code:

$('#pageForward').append(' detailUser +','+ detailDate +','+ detailUserName + ','+ previousPage +');"开发者_开发技巧> >>');

The string builds, but if my variables are null, I get a syntax error:

[Break On This Error] getSDDetailPopUp(Accounting,,,,2);

How do I get this string to be this: getSDDetailPopUp(Accounting,'','','',2);

Thanks!


use || as a null coalescing operator.

... detailUser || "" + ...


For each of your params you can just do...

(detailUser != null ? detailUser : "''")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜