How to bind click event to object tag?

前端 未结 2 2059
Happy的楠姐
Happy的楠姐 2020-11-30 12:39

I have this code


and jquery



        
2条回答
  •  独厮守ぢ
    2020-11-30 13:15

    The easiest way to accomplish this goal is to wrap the object tag in a div, bind the click listener to the div, and add pointer-events: none to the object tag's styles.

    Sample fiddle:

    .clickable {
      background: red;
      width: 100px;
      height: 100px;
      border-radius: 100px;
      overflow: hidden;
    }
    
    object {
      width: 100%;
      pointer-events: none;
    }

    提交回复
    热议问题