Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

253
Views
How to disable link on Button but when I click on card link should be work

I am Using card and when i click on card its work fine. Now i have added three buttons in cards when i click on button then card link also call. i just want to perform different action from button but not card link.

When i click on Pizza its working fine but when i click on S, M, L Buttons then same link calling on these button

This is code:

<li class="t-Cards-item #CARD_MODIFIERS#" data-id="#ID#" >
  <div class="click t-Card" >
    <a href="javascript:void(null);" class="t-Card-wrap" data-id="#ID#">
      <div class="t-Card-icon u-color #CARD_COLOR#"><span class="t-Icon fa #CARD_ICON#"><span class="t-Card-initials" role="presentation">#CARD_INITIALS#</span></span></div>
      <div class="t-Card-titleWrap"><h3 class="t-Card-title">#CARD_TITLE#</h3>
      <h4 class="t-Card-subtitle">#CARD_SUBTITLE#</h4></div>
        <div id="outer">
        <div class="inner"><button  class="msgBtn"   >S</button></div>
        <div class="inner"><button  class="msgBtn2" onClick="return false;">M</button></div>
        <div class="inner"><button  class="msgBtnBack">L</button></div>
        </div>
       
      <div class="t-Card-body">
        <div class="t-Card-desc">#CARD_TEXT#</div>
        <div class="t-Card-info">#CARD_SUBTEXT#</div>              
          
      </div>
      <span class="t-Card-colorFill u-color #CARD_COLOR#"></span>
    </a>
  </div>
   
</li>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The Problem

Assume there are two divs with two different buttons on them.

<div onClick={handleOutter}>
  <div onClick={handleInner}>
    // some content ...
  </div>
</div>

calling handleOutter will call the handleInner function. this is the default behavior of event propagation in your elements. more info on MDN documentation.

The Solution

You can stop event propagation in the child elements by adding event.stopPropagation() in the handler function in this way:

const btn = document.getElementById('myParentElement');

btn.onclick = function (event){
  event.stopPropagation();
  // ...
}

more info on MDN documentation.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!