내가 이루고 싶은 것을 이미지로 설명하고, 더 쉽다고 생각합니다.
나는 이것을 시도했지만 작동하지 않습니다
$('.entry-tpl-grid').each(function(){
$(this).on('click', function(){
location.href = $(this).find('div > header > h3> a').attr('href');
});
});
<article class="entry-tpl-grid">
<figure class="entry-featured-media">
<a href="#" class="g1-frame">
<div class="g1-frame-inner">
<img src="https://--.com/300x300.png">
</div>
</a>
</figure>
<div class="entry-body">
<header class="entry-header">
<h3 class="entry-title">
<a href="https://www.--.com/" class="woocommerce-LoopProduct-link"> Product name </a>
</h3>
</header>
</div>
</article>
미리 감사드립니다.
를 사용 [0]
하여 DOM 요소에 직접 액세스 한 다음 표준 JS를 사용할 수 있습니다..click()
$('.entry-tpl-grid').on('click', function() {
$(this).find('div > header > h3 > a')[0].click();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<article class="entry-tpl-grid">
<figure class="entry-featured-media">
<a href="#" class="g1-frame">
<div class="g1-frame-inner">
<img src="http://placekitten.com/150/150">
</div>
</a>
</figure>
<div class="entry-body">
<header class="entry-header">
<h3 class="entry-title">
<a href="https://www.--.com/" class="woocommerce-LoopProduct-link"> Product name </a>
</h3>
</header>
</div>
</article>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다