Search code examples
javascriptcssbuttonhref

Clickable Button inside 'a' Tag


When I click tag <button>, tag <a> clicked directly. How to solve it? or any other way? enter image description here


Solution

  • tag <button> is child of tag <a>, that's why tag <a> clicked when you click <button>. Create tag <button> as sibling of tag <a> and position it over image with the help of css.

    <a href="#">
       <image src="">
    </a>
    <button>View<button>
    

    Also use higher z-index for <button> to make it over tag <a>.