I’m a student and cannot wrap my head around why this isn’t working.
function addedToCart(x)
{
alert( x.value + " has been added to cart\nPress OK to continue.");
}
<a href="#" value="blue circle" onclick="addedToCart(this)">
Any help is appreciated!
Because
valueis not a valid attribute for an anchor<a>. It’s intended to be used for form elements, such asinputorselect.A more appropriate (and with valid markup) solution would be to use HTML5
data-*attributes, and then fetch it usinggetAttributeas suggested by @Jeffrey Sweeney:And then: