Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JavaScript获取没有id的输入值?_Javascript_Jquery_Html_Asp.net Mvc_Datatable - Fatal编程技术网

如何使用JavaScript获取没有id的输入值?

如何使用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属性作为目标,我看

我有一个可编辑的数据表,在编辑模式下,生成的html如下所示:

<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
});