Javascript 设置';src&x27;使用主干模板动态生成img标签
我正在尝试使用主干模板动态设置Javascript 设置';src&x27;使用主干模板动态生成img标签,javascript,backbone.js,Javascript,Backbone.js,我正在尝试使用主干模板动态设置img标记的src,但是/会自动追加img未加载的标记。模板部分如下所示- <script type="text/template" id="home"> ....... <% var d=names[0].get("image_link")+".jpg" //d=d.substring(0 , d.length-1); tried to cut down last char %> <a href="#" class="thumbna
img
标记的src
,但是/
会自动追加img
未加载的标记。模板部分如下所示-
<script type="text/template" id="home">
.......
<% var d=names[0].get("image_link")+".jpg"
//d=d.substring(0 , d.length-1); tried to cut down last char
%>
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src=<%=d%> />
.......
</script>
.......
/>
.......
输出-
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src="image1.jpg/" />
我不知道如何在
img
src中排除/
。请给我任何建议。代码中实际上有斜杠。由于属性值周围没有任何引号,因此/
中的/
将成为该值的一部分
添加引号:
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src="<%=d%>" />
“/>
斜杠实际上在代码中。由于属性值周围没有任何引号,因此/
中的/
将成为该值的一部分
添加引号:
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src="<%=d%>" />
“/>
斜杠实际上在代码中。由于属性值周围没有任何引号,因此/
中的/
将成为该值的一部分
添加引号:
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src="<%=d%>" />
“/>
斜杠实际上在代码中。由于属性值周围没有任何引号,因此/
中的/
将成为该值的一部分
添加引号:
<a href="#" class="thumbnail"><img class="img-responsive ui-corner-all" width="100%" height="auto" src="<%=d%>" />
“/>