本文介绍了有没有其他选项可以包含来自JavaScript的'input'元素而不使用单引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  $('< input class =btntype =buttonvalue =[[[send]]]title =/>').insertAfter ( '#something'); 

当我将这个输入元素从js包含到html时,我使用单引号(')。如果您看到值属性 value =[[[send]]]我已经使用方括号进行本地化。如果翻译的语言包含单引号(法语,意大利语),我会在脚本中获取')'缺少错误

EX: $('< input class =btntype =buttonvalue =send'varatitle =/>').insertAfter('#something');



是否有任何选项可以包含输入元素而不使用单引号?或者在JS中有单引号的其他表示形式?

解决方案

请尝试以下操作:

  $('< input>',{class:btn,type:button,value:[[[send]]],title :})


 $('<input class="btn" type="button" value="[[[send]]]" title="" />').insertAfter('#something');

When I include this input element from js to html, I am using single quotes('). If you see value attribute value="[[[send]]]" I have used brackets for localization. If the translated language contains single quotes(french, italian) I am getting ')'missing error in script.

EX: $('<input class="btn" type="button" value="send'vara" title="" />').insertAfter('#something');

Is there any option to include input element without using single quotes ? or Is there any other representation for single quotes in JS ?

解决方案

Try the following:

$('<input>', { class:"btn",type:"button",value:"[[[send]]]",title:""})

这篇关于有没有其他选项可以包含来自JavaScript的'input'元素而不使用单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:22