ajax中拼接数据实现点击onclick方法

 success: function (data) {

                  var ulLi = '';

                  var contentStr = '';

                  if (data.data == null) return false;

                  data.data.forEach((item3, index3) => {data.total;

                    var currentNumber = index3+1

                    var str2 = '<li><a class="auxiliaryText" href="#">' + currentNumber + '.' + item3.name + '</a></li>'

                    contentStr += str2;

                    ulLi = "<ul class='sonCollectionList' οnclick='clickCollection(\""+item3.topic_collection_id+"\",\""+item2.name+"\",\""+data.total+"\")'>" + contentStr + "</ul>";

                  });

                  sonsStr1 += (str1 + ulLi + str3);

                  var contentStr1 = str + '<div class="visualModule" id="visualModule"><div class="topicCollectionContent clearfix" id="slideModule">' + sonsStr1 + '</div></div>'+

                  '<div class="slideLeft" id="slideLeft"><i class="iconfont">&#xe7ec;</i></div><div class="slideRight" id="slideRight"><i class="iconfont">&#xe7ed;</i></div>'

                  allTopicContent = '<div class="topicCollectionWrap">' + contentStr1 + '</div>';

                  allTopicContentArr[index] = allTopicContent;

                  finalStr = allTopicContentArr.join('');

                  $(".bigBox").html(finalStr);

                  $(".sonCollectionContent").each((index4, item4) => {

                    item4.setAttribute("id", collectionIdArr[index4]);

                    item4.setAttribute("collectionname", collectionNameArr[index4]);

                  })

 

function clickCollection(id,name,total) {

    _hmt.push(['_trackEvent', '题目合集', '题目合集点击次数', '题目合集']);

    var val = encodeURI(name);    

    val = encodeURI(val);

    var brushContentUrl = 'brushContent.html?uid='+id+'&uname='+val+'&total='+total;

    localStorage.removeItem('saveTopicId');

    localStorage.removeItem('saveIndex');

    window.open(brushContentUrl);

 

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值