0

I'm having an issue making my image clickable. It is a cart style photo with a little number bubble that tells you how many items you have in the cart. The div is clickable but the photo itself is not.

Here is my code:

 <a routerLink="/cart">
    <img class="cart" src="../../../assets/canoe detail.png" alt="Canoe Cart">
    <div *ngIf="quantity" class="quantity">{{quantity}}</div>
 </a>

I have also tried adding a click event to the image with a function just logs ("clicking") and I have also tried adding "routerLink='/cart'" to the image tag as well, but neither of these worked.

What am I missing?

Thank you in advance!!

2
  • probably an easy solution would be to encapsulate both image and div in a parent div and asign there the click event. not sure if that works for you.
    – monxas
    Commented Apr 8, 2021 at 14:39
  • @monxas Thank you for the reply. Unfortunately that did not work Commented Apr 8, 2021 at 15:16

3 Answers 3

1

Your code seems fine, should work

<a class="brand-logo" routerLink="/login">
 <img src="assets/img/logo-svg.svg" />
</a>

Try removing the other div and check, but should work even with it. This works for me

0
0

Add this CSS for a

a{display:inline-block}
1
  • Thanks for the reply, Unfortunately that did not work Commented Apr 8, 2021 at 15:16
0

Solved! Even though it was visible, it was behind the navbar so changing the z-index fixed it.

a {
  z-index: 5;
}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.