帝国cms内容页实现点击按钮后js随机跳转到一篇文章

上代码:

<script>
	function randArticle1(){
		let as=$(".click-ul").children("li");
		url=$(as[Math.floor(Math.random()*as.length)]).children("a").first().attr("href");
		if(url==''||url==window.location.href){self.location.href=$("#typelink").attr('href')}else{self.location.href=url}};
</script>




      <ul class="click-ul">
[e:loop={'selfinfo',10,0,0,'','newstime DESC'}]
        <li>
          <em>
            <?=$bqno?>
          </em>
          <a href="<?=$bqr['titleurl']?>">
            <?=$bqr['title']?>
          </a>
        </li>

[/e:loop]
      </ul>

分析:

[e:loop={'selfinfo',10,0,0,'','newstime DESC'}]
        <li>
          <em>
            <?=$bqno?>
          </em>
          <a href="<?=$bqr['titleurl']?>">
            <?=$bqr['title']?>
          </a>
        </li>

[/e:loop]

 

点击按钮后,这个灵动标签循环中随机抽取一篇文章跳转。

参考效果:http://m.zym.cncobo.com/article/lizhizuoyouming/131.html

图片[1]-帝国cms内容页实现点击按钮后js随机跳转到一篇文章-HostJL-VPS主机交流

© 版权声明
THE END
喜欢就支持一下吧
点赞14 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容