How to get element id using javascript / jquery

Question:

The page has

<td id="#X"><input id="status" name="status"></td>

I need to use AJAX to update the content of the database in accordance with what is written in the field. The parameter line looks like this:

data: 'action=setStatus&status=' + t.value + '&id=' + document.getElementById("...ID ?").value,

How can I get the ID of TD instead of "document.getElementById (" … ID? "). Value"?

Answer:

Get parent – .parentNode. Get id – .id

var inp = document.getElementById('status');
var td = inp.parentNode;
var ID_of_TD = td.id;
console.log(ID_of_TD); // "x"

http://jsfiddle.net/b12evuph/

Scroll to Top