-4

I have to disable link in the image so that the user can not click on that image what can I do ?

code -

<a href={fb} target="_blank" onClick={(e) => {
  e.stopPropagation();
}}>
 <span style={{ fontSize: '17px', color: '#1930f42a' }} >
    <img className='logo' src={Fb} height={28} />
 </span>
</a>
  • i think this will help you https://stackoverflow.com/questions/18083061/make-element-unclickable-click-things-behind-it – Raga Pushadwa Jan 11 '21 at 08:35
  • What have you tried already? It's also odd to attach an `href` ***and*** `onClick` handler to an anchor tag. Can you provide an example of what you've tried? – Drew Reese Jan 11 '21 at 08:35

2 Answers2

0

I think you want to prevent redirect when clicking on link

e.preventDefault();
Teo Em
  • 21
  • 3
0
<a href={fb} target="_blank" onClick={(e) => {
  e.preventDefault()
}}>
 <span style={{ fontSize: '17px', color: '#1930f42a' }} >
    <img className='logo' src={Fb} height={28} />
 </span>
</a>

You need to use e.preventDefault() to prevent the default behavior of the link

linchong
  • 485
  • 2
  • 4