點擊DIV觸發其他元素的點擊事件(案例:點擊type="radio" 的input 標簽外層DIV,觸發內部單選點擊選中事件)


 

方法一:

直接用找到對應dom元素調用.click()方法

$('.user_content').click(function(){
    $(this).children()[0].click();  //Dom元素執行點擊事件
  //或者Dom元素執行點擊事件

$(this).children('input[type="radio"]')[0].click();
}

 

 

方法二:

參考:https://blog.csdn.net/qq_37000055/article/details/101562653

html

<div class="tempStyle" @click="checked($event)">
      <input class="hy-radio" type="radio" name="a"><label>選項1</label>
    </div>
    <div class="tempStyle" @click="checked($event)">
      <input class="hy-radio" type="radio" name="a"><label>選項2</label>
    </div>

對應js

method: {
    checked(e) {e.currentTarget.firstElementChild.click();}      
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM