I am trying to change the text of a label in JQuery, when that label is clicked.
This code works when I refer to the control ('ACCP') using its exact name:
$("label[for='ACCP']").text("the new text");
But I want to be able to refer to the control using a variable, not its exact name. This doesn't work:
$("label[for=' + this.id + ']").text("the new text");
I am quite sure the right control is behind this.id
, because when I pop up a message to retrieve the id for the current control, it gives me the expected control name:
var ctrlName = this.id;
alert(ctrlName);
-> correctly returns 'ACCP' in this case.
I am probably missing an obvious syntax error in my code, but I never do JQuery - my code is all copy-paste ;)
Thanks in advance for your precious help, JM