一个单引号的小问题,研究了好久,终于出来,写个博客记录一下。

一个单引号的小问题,研究了好久,终于出来,写个博客记录一下。

——————————————————————————————————————————————————

jsp页面:

<div class="col-lg-2 col-sm-2 col-xs-2">
<a οnclick="addFile1()">
<h5 class="row-title" ><i class="fa fa-tags blue"></i>添加子工程:</h5>
</a>
</div>
<table wisth="100%" class="table table-striped">
<tbody id="MyFile">
<tr>

<td height="45px" width="125px">子工程名称</td>
<td>工程类型</td>
<td>子工程预算 </td>
<td> 物料清单</td>
<td height="45px" width="125px"> #</td>
</tr>
<tr>
<td height="45px" width="20%">
<input id="" name="" type="text"
class="form-control" placeholder="子工程名称">
</td>
<td height="45px" width="20%">

<input id="" name="" type="text"
class="form-control" placeholder="工程预算">
</td>
<td>
<div class="input-group">
<div class="input-group-btn">
<button type="button"
class="btn btn-default dropdown-toggle"
data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<c:forEach items="${ProjectTypeItems}" var="Items">
<li>
<a href="JavaScript:SetZxsgcs(${Items.id},'${Items.typeName}',1);">
${Items.typeName}</a>
</li>
</c:forEach>

</ul>
</div>
<input id="1_id" name="1_id"
type="hidden">
<input id="1_sgcs" name="zxsgcs" type="text"
class="form-control" placeholder="请选择工程类型">
</div>
</td>

<td>
<a href="JavaScript:UploadList(1);" class="btn btn-success">
<i class="fa fa-upload"></i>上传物料清单 </a>
</td>

<td height="45px" width="125px">
#
</td>
</tr>
</tbody>
</table>


——————————————————————————————————————————————————————————————

js代码:


//绑定下拉框

function SetZxsgcs(jlid, jlmc, num) {
$('#' + num + "_id").val(jlid);
$('#' +num+ "_sgcs").val(jlmc);
}

//添加子工程

var i=2;
function addFile1(){
var str = '<tr><td height="45px" width="20%"><input id="" name="" type="text" class="form-control" placeholder="子工程名称"></td>'+
'<td height="45px" width="20%"> <input id="" name="" type="text" class="form-control" placeholder="工程预算"> </td>'+
'<td><div class="input-group"><div class="input-group-btn"><button type="button"class="btn btn-default dropdown-toggle"data-toggle="dropdown">'+
'<span class="caret"></span></button><ul class="dropdown-menu">'+
'<c:forEach items="${ProjectTypeItems}" var="Items"><li>'+
'<a href="JavaScript:SetZxsgcs(${Items.id},&quot;${Items.typeName}&quot;,'+i+');">${Items.typeName}</a></li>'+
'</c:forEach> </ul></div><input id="'+i+'_id" name="'+i+'_id" type="hidden">'+
'<input id="'+i+'_sgcs" name="zxsgcs" type="text" class="form-control" placeholder="请选择工程类型"></div></td>'+
'<td> <a href="JavaScript:UploadList('+i+');" class="btn btn-success"><i class="fa fa-upload"></i>上传物料清单</a></td>'+
'<td height="45px" width="125px">#</td></tr>' ;
alert(str);
document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str);
i++;

};

————————————————————————————————————————————————————————

SetZxsgc()方法中的第二个参数是字符型的,必须加单引号,单引号里面的单引号用&quot;代替。

————————————————————————————————————————————————————————

总结:

1,单引号里面的单引号用&quot;代替。

2,单引号里面的转义字符\用\\代替。

3,如果外边是双引号,里边的是双引号要变单引号;如果外边是单引号,里面双引号不变。

转载于:https://www.cnblogs.com/luoshui-xiao/p/5826556.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值