I\'m doing a validation with Jquery and need to get the $label from each element with their own label. Now the alert() gives med [object object]. The best thing for me here
Improving upon the answer you could wrap it in a function:
function getLabel(name) { var $label = $("label[for='" + name + "']") return ($label.text()); } var label = getLabel(this.id); console.log(label);
This makes it much easier to reuse the code.