Hi. I'm relatively new to JQuery and despite several Google searches, I can't seem to find an answer to what I thought was a relatively obvious question.
I'm creating several checkboxes using this method:
var box = $("<input>").attr("type", "checkbox")
.attr("name", name).val(name)
.change(changeTraits);
Then, in the method "changeTraits()" I need to access the checkbox whose change triggered the event. I've seen how to do this using the ".on" or ".one" method of assigning handlers, but not using this method. This is my current attempt that isn't working:
function changeTraits()
{
window.alert(event.currentTarget.val());
}
I also tried it by passing in a parameter with the name "event", but I still get an error because "event" is undefined. I'm sure I'm missing something really obvious, but it's so obvious that no one seems to have explained it. Or, maybe I'm just not wording the question correctly. Anyway, any help would be appreciated!