如何使用JavaScript获取没有id的输入值?
我有一个可编辑的数据表,在编辑模式下,生成的html如下所示:如何使用JavaScript获取没有id的输入值?,javascript,jquery,html,asp.net-mvc,datatable,Javascript,Jquery,Html,Asp.net Mvc,Datatable,我有一个可编辑的数据表,在编辑模式下,生成的html如下所示: <td><form><input autocomplete="off" name="value" ></form></td> 您可以使用document.querySelector: 或者,使用jQuery,也可以使用相同的选择器: var input = $('[name="value"]'); 您的问题很难理解,您可以直接使用jQuery将name属性作为目标,我看
<td><form><input autocomplete="off" name="value" ></form></td>
您可以使用document.querySelector:
或者,使用jQuery,也可以使用相同的选择器:
var input = $('[name="value"]');
您的问题很难理解,您可以直接使用jQuery将name属性作为目标,我看到您使用的是jQuery,而不是JavaScript,并获取输入值use.val,如下所示:
$("input[name='value']").val();
然后您可以得到currentInput.value
var input = $('[name="value"]');
$("input[name='value']").val();
var currentInput=null;
$("input").focus(function(e)
{
currentInput=e.target or this;//here you can get currently editing textfeild or may be $(this) if this is wrong
});