我有来自服务的JSON。我要按JSON值附加html块,并且必须检查一些值以进行适当的显示。 我正在尝试设置DiscountValue变量,但不能与js变量一起使用。我该怎么解决?
if (data!="")
{
$.each(data,function(index,element){
var intDiscount=parseInt(10);
console.log("intDiscount::"+intDiscount);
var strIndex='';
strIndex+='<div class="card">';
strIndex+='<c:set var="discountValue" value="'+intDiscount+'"/>';
console.log("${discountValue}");
...
...
...
...
}
$('#visilabs-FavouriteCategoryTopSeller').append(strIndex);
控制台日志:
intDiscount::10
0
答案 0 :(得分:0)
我已经通过在js中使用if条件解决了这个问题:
if(element.discount>0){
strIndex+= ' <span class="label label-danger discount">'+'% '+intDiscount+'</span>';
}
谢谢大家