Push html attribute to array onClick
Posted
by
Hunkeone
on Stack Overflow
See other posts from Stack Overflow
or by Hunkeone
Published on 2013-10-30T21:46:30Z
Indexed on
2013/10/30
21:53 UTC
Read the original article
Hit count: 166
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 :(
© Stack Overflow or respective owner