Push html attribute to array onClick
- by Hunkeone
I'm trying to push number attribute of the element to the array onclick with a simple function, but array contains only empty values separated with commas.
Here's html code.
<button type="button" class="btn btn-success btn-lg" number="12" onclick="basket.push(this.number)">toBakset</button>
<button type="button" class="btn btn-success btn-lg" number="15" onclick="basket.push(this.number)">toBakset</button>
<button type="button" class="btn btn-success btn-lg" number="18" onclick="basket.push(this.number)">toBakset</button>
from the start "basket" array is empty.
Seems this question is so dumb but I can't find a solution :(