views:

48

answers:

3

For

<span id="" ...>
  <input id="" ...>

Is there any way to retrieve span id? input element is embedded within span?

+3  A: 
document.getElementById("inputId").parentNode;
Marius
+2  A: 

If you're using jQuery:

$('#input-id').parent().attr('id');

If not:

document.getElementById('input-id').parentNode.getAttribute('id');

EDIT: Ooops - removed extra parentheses after parentNode!

Mark B
A: 
var parentControl = document.getElementByID("id goes here").parentNode;
jmein