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

173
Views
How to disable redirecting for some elements in an anchor tag?

I have the following code :-

<a href="/">
 <h1>Hello Wolrd</h1>
 <p>This is some description</p>
 <div>....this is Image Carousel</div>
 <div class="dotButton>
   <button></button>
   <button></button>
   <button></button>
 </div>
</a>

Here I put a image carousel with dot button in a link tag. Here I face one problem. When I click the card it redirects href link for using a tag. But problem is when I click dot button to slide the images, it ridirect href link. How can I disable href and working dot button for sliding images.

Thank you!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use this :

<a href="javascript:void(0)">
 <h1>Hello Wolrd</h1>
 <p>This is some description</p>
 <div>....this is Image Carousel</div>
 <div class="dotButton">
   <button></button>
   <button></button>
   <button></button>
 </div>
</a>

And after that when you will click the image it will not redirect you anymore.

about 4 years ago · Juan Pablo Isaza Report

0

You can use onClick handler function if you want to run some logic like this:

// for functional Components

const handleClick=(e)=>{
     e.preventDefault();
    // write your logic for on click
}

 <a onClick={handleClick}>
   <h1>Hello Wolrd</h1>
   <p>This is some description</p>
   <div>....this is Image Carousel</div>
   <div class="dotButton">
     <button></button>
     <button></button>
     <button></button>
   </div>
</a>

with this you can do your other stuff on clicking the anchor without redirecting.

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!