【发布时间】:2013-08-26 20:11:02
【问题描述】:
我创建 WordPress ShortCode 选项卡并编写此代码来收集简码
jQuery('body').on('click', '#tapSubmit',function(){
var shortcode = '[tapWrap]';
jQuery('.tapForm').each(function(){
var title = jQuery('.Title').val(),
content = jQuery('.Content').val(),
shortcode += '[tap ';
if(title){shortcode += 'title="'+title+'"';}
shortcode += ']';
if(content){shortcode += ''+content+'';}
shortcode += '[/tap]';
});
shortcode += '[/tapWrap]';
tinyMCE.activeEditor.execCommand('mceInsertContent', false, shortcode);
});
我得到这个错误
Uncaught SyntaxError: Unexpected token if
我尝试了http://jsfiddle.net/ 中的代码,但在包含此代码的行中出现了此错误
shortcode += '[tap ';
Expected an assignment or function call and instead saw an expression.
如何解决?
【问题讨论】:
-
从 var 定义链中删除这个
shortcode += '[tap ';。否则,您再次定义它,没有任何价值可添加。
标签: javascript jquery wordpress tinymce