简体   繁体   English

从输入类型获取值,该输入类型附加在javascript中的表中

[英]Get value from input type which is append in table in javascript

I have an issue to get a value from input box. 我在从输入框获取值时遇到问题。 This input type is used in a table td in javaScript code. 此输入类型在javaScript代码的表td中使用。 The code looks like: 代码如下:

var markup = "<tr id ='row"+idd+"' class info'>";
 markup += "<td>"+select box text+"<input class='test' name='example["+id+"][name]'
type='hidden' value='"+select box option value+"'></td>";

$("table tbody").append(markup);

now I want to get the value of input type. 现在我想获取输入类型的值。 How can I get? 我怎样才能得到? Please help. 请帮忙。 :) :)

When you are generating markup, give input a class, say class="desiredinput" 生成标记时,请给输入一个类,例如class="desiredinput"

Now to fetch its value, do: 现在要获取其价值,请执行以下操作:

$(".desiredinput").val();

Add id attribute in input tag like this id="inputTypeID" input标签中添加id属性,例如id="inputTypeID"

then you can get it's value using JQuery (Make sure you have included JQuery library) 那么您可以使用JQuery来获取它的价值(确保已包含JQuery库)

 $("#inputTypeID").val();

and without JQuery : 并且没有JQuery

document.getElementById("inputTypeID").value;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM