想要实现鼠标点击事件,如何使用script来完成?

想要通过点击该文字然后转到另一处地方,不用超链接,用script如何完成实现该功能?
点击前

img

点击后

img

当点击陪同看车的时候将陪同看车下的内容显示出来,


<span id="peitong">陪同看车</span>

<div class="peitong-content">陪同看车下的内容</div>

<script type="text/javascript">
     let peitong = document.getElementById("peitong");
      let peitong_content = document.getElementByClass("peitong-content")
peitong.click(function() {
         peitong_content .style.display=true;           
       
       })
</script>

通过操作Dom的方式来实现,动态的隐藏显示效果。首先获得点击的标签 doment.getElementById(),然后动态设置当前的display 属性即可!

window.location.href 跳转页面