hexadecimal hexadecimal - 1 year ago 92
HTML Question

How to get input value with no id using JavaScript?

I have an editable DataTabe and when edit mode, the generated html is exactly as shown below:

<td><form><input autocomplete="off" name="value" ></form></td>

There is s TextBox as input and I need t get the value of this input. However, I cannot give id as there is no configuration of DataTable and I decided to get the value using Javaascipt. I have tried many different methods like closest() as shown below, but cannot get the value. Is it possible to grab it?

var $row = $(this).closest("tr");
$tds = $row.find("td");

Answer Source

You might use document.querySelector:

var input = document.querySelector('[name="value"]`);

Or, using jQuery, you could also use the same selector:

var input = $('[name="value"]');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download