Im trying to give this set of font awesome icons to be clickable ( so when I click on them, I get directed to the page I want)

<i class="fas fa-chart-line"></i>

<i class="fas fa-utensils"></i>

<i class="fas fa-newspaper"></i>

<i class="fas fa-user"></i>

<i class="fas fa-sign-out-alt"></i>

How can I accomplish this with Javascript or if there is another way to work around it? I know that you can do this by wrapping the icons with <a href="" , but I'm just looking for another way to do it

1 Answers

Community On

onclick Event


<button onclick="myFunction()">Click me</button>

Syntax In HTML:

<element onclick="myScript">

In JavaScript:

object.onclick = function(){myScript};

In JavaScript, using the addEventListener() method:

object.addEventListener("click", myScript);