使用js判断当前是手机端还是PC端,并点击相应的地方跳转
使用jQuery attr()方法,attr() 方法设置或返回被选元素的属性和值
html部分
<a id="complaint" class="wf mgtop10 center relative home-icon">
<img src="../model20190807/image/sfts.png"/>
<p>消费投诉</p>
</a>
js部分
<script>
if(/Android|webOS|iPhone|iPod|BlackBerry|iPad|SymbianOS/i.test(navigator.userAgent)) {
$("#complaint").attr('href', 'http://gsxt.ynaic.gov.cn/wechat/wap/tsjb/index.html');
} else {
$("#complaint").attr('href', 'http://gsxt.ynaic.gov.cn/consumerw/sgsreg.jsp');
}
</script>