How to retrieve an input element and its surrounded span?
For
<span id="" ...>
<input id="" ...>
开发者_运维知识库
Is there any way to retrieve span id? input element is embedded within span?
document.getElementById("inputId").parentNode;
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!
var parentControl = document.getElementByID("id goes here").parentNode;
精彩评论