javascript中使用的双引号

double quotes use in javascript

本文关键字:javascript      更新时间:2023-09-26

我添加了一个隐藏的输入,因为选择中的某些内容是选择的,使用带有一些jsp变量的onchange事件。我在正在处理的div中添加了一些文本,但引号和双引号太多了,所以我不知道该怎么做。有人知道吗?

<select name="opt_name%>" onchange="$('#dati_opzioni').append('<input type="hidden" name="optdesc_'+<%=opt.getCdOpzione()%>+'" value="'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'"/>');">

尝试在onchange="…"中使用html实体进行双引号(如不带空格的&quot;)

<select name="opt_name%>" onchange="$('#dati_opzioni').append('<input type=&quot;hidden&quot; name=&quot;optdesc_'+<%=opt.getCdOpzione()%>+'&quot; value=&quot;'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'&quot;/>');">

试试这个:

<select name="<%=opt_name%>" onchange="$('#dati_opzioni').append('<input type=""hidden"" name=""optdesc_'+<%=opt.getCdOpzione()%>+'"" value=""'+<%=optLabel%>+'_'+this.options[this.selectedIndex].text+'""/>');">