[自用门户]需求:公告发售结束时间大于当前时间时候,则在类加on,显示new图标(主要看js实现方法)

xiaoxiao2021-02-28  107

js部分

<script type="text/javascript" language="javascript"> /* SuperSlide1.2 */ (function($){ $(function() { //mark 20170831:修改逻辑公告发售时间大于等于当前时间,则加属性on,显示new图标 //定位到endTime类 $(".endTime").each(function(){ var thetime =$(this).attr("value");//获取当前value的时间赋值给thetime var d=new Date(thetime);//把thetime赋值给d变量 var curDateb = new Date();//获取当前时间 console.log(d+'<br/>'+curDateb); //curDateb.setDate(curDateb.getDate() - 3); //当公告发售时间大于等于当前时间则,加on if(d >=curDateb){ $(this).parent().addClass("on");//在父级class加on属性 } }); }); })(jQuery); </script>

html部分

<span class="bidLink timeb" id="cghw-${c_index}-time"> <input type="hidden" value="${(c.attr.endDate)!'无数据'}" class="endTime cghw-${c_index}-time" t="cghw-${c_index}-time">[@text_cut s=c.title len=titLen append=append/] </span> <span class="bidDate biddleft">${(c.date?string(dateFormat))!''}</span>

判断符合条件的则会在class加on如下

class="bidLink timebon"

转载请注明原文地址: https://www.6miu.com/read-28426.html

最新回复(0)