我創建WordPress的簡碼標籤,寫這樣的代碼來收集簡碼未捕獲的SyntaxError:意外的標記,如果
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);
});
和我得到這個錯誤
,我嘗試在http://jsfiddle.net/和我的代碼得到這個錯誤的代碼行
shortcode += '[tap ';
Expected an assignment or function call and instead saw an expression.
如何解決它?
刪除此'簡碼+ = '[點擊';'從VAR定義鏈。否則,你再次定義它,沒有值添加到。 – Sergio
感謝它的工作:) –