• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • Last Modified:

ExtJS Question: Retrieving id of label?

I'm trying to return the name of a label once a checkbox has been selected.

The html looks like this:
<label name="myName"><input type="checkbox" id="n1" name="n1" value="2" /></label>

I've tried:

var checkboxid = $('n1');
var label = parent.checkboxid;
var labelname = label.name;
 
alert(labelname);

Open in new window

0
n00b0101
Asked:
n00b0101
  • 3
  • 2
1 Solution
 
hieloCommented:
try:
var checkboxid = $('n1');
var label = checkboxid.parentNode;
var labelname = label.name;
0
 
n00b0101Author Commented:
I tried the above, and I also tried:

var checkboxid = $(this);
var label = checkboxid.parentNode;
alert(label.name);

And just get: label is undefined
0
 
hieloCommented:
make sure no other element has:
id="n1"

then try:
var labelname =$("#n1").parent().name;
0
 
n00b0101Author Commented:
sorry so late!
0
 
hieloCommented:
glad to help
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now