pick up a value from the button

help me get the value from the button, I can not

my code:

   <a href="" onclick="funk(this)" value="123" class="price-button"><i class="fas fa-shopping-cart"></i> press</a>
    <script>
     funk = (a) => {
    console.log(a.value)
    
    }
    </script>

>Solution :

Set a value in HTML and retrieve it on click with getAttribute

<a href="" value="123" class="price-button" onclick="funk(this)"><i class="fas fa-shopping-cart"></i> press</a>
const funk = (a) => {
    console.log(a.getAttribute("value"))
}

Leave a Reply