I'm working on a codecademy.com lesson that's teaching me how to build a bar graph with jQuery. The last set of instructions are to add a click event to $bar to display it's value. It explains
Anonymous functions go like this:
function(arg) { code }. In this case, a .click handler will have e, the click event, as its argument, so your implementation should havefunction(e) { alert code }within the.click().
Here's the function I'm supposed to modify
// Exercise 5
function addBarClickEvent($bar,value) {
// add a click event to the bar that
// pops up an alert with the bars value
$bar.click(
// your code goes here!
}
);
}
I tried both of the solutions shown below but neither worked. The lesson doesn't provide a solution unfortunately. Can anyone help.
// Exercise 5
function addBarClickEvent($bar,value) {
// add a click event to the bar that
// pops up an alert with the bars value
$bar.click(
// your code goes here!
alert($bar.value) //my attempt
alert(e.value) //my second attempt
}
);
}
I'm getting this error message
Make sure to define the argument to .click as an anonymous function that displays the alert.
function(){part