Javascript 如何使用jQuery获取表中每列的值?
我有一个带有下拉列表的表。下拉列表的值来自本地db菜单,我正在尝试使用jQuery获取所有列的值,但我使用的代码不起作用。如有任何帮助,将不胜感激。谢谢。 注意:我使用克隆方法在表中动态添加新行 jQuery HTML 基于选择器获取元素后,可以使用。每个函数: 函数fnOnSubmit{ $'dataTable输入:非[type=button],dataTable选择'.eachfunction{ console.logthis.name+':'+this.value; }; } 链接 描述 形象 统一资源定位地址 选择Javascript 如何使用jQuery获取表中每列的值?,javascript,jquery,html,Javascript,Jquery,Html,我有一个带有下拉列表的表。下拉列表的值来自本地db菜单,我正在尝试使用jQuery获取所有列的值,但我使用的代码不起作用。如有任何帮助,将不胜感激。谢谢。 注意:我使用克隆方法在表中动态添加新行 jQuery HTML 基于选择器获取元素后,可以使用。每个函数: 函数fnOnSubmit{ $'dataTable输入:非[type=button],dataTable选择'.eachfunction{ console.logthis.name+':'+this.value; }; } 链接 描述
这回答了你的问题吗?是的,它成功了。非常感谢。而且,如果每次我从下拉列表中获取值时您都能提供帮助,我希望它在同一个循环中附加值。@Saurav当然可以。从下拉列表中获取值后,您希望将值附加到何处?函数从下拉列表中获取值后,应立即使用@Saurav进行附加。您的意思是:从下拉列表中获取值,然后将其附加到带有id的标记,然后从所选选项标记中引用id。对吗?我很抱歉,我希望它是前置的,而不是附加的。从您建议的函数中,我将来自字段并存储在var标志中的每个值附加到“~”,它看起来类似于此标志=Guides~D1~i1~U1~最新报价~d2~I2~U2~。所以我想在下拉列表的值前面加上。
function fnOnSubmit() {
var formvalue = $( "#dataTable" ).serializeArray();
jQuery.each(formvalue, function(i, formvalue){
alert(formvalue.name+':'+formvalue.value);
});
}
<table border="0" cellspacing="1" cellpadding="1" id="dataTable" class="graphtable">
<thead>
<tr>
<td class="headingalign" width="16%">Links</td>
<td class="headingalign" width="32%">Desciption</td>
<td class="headingalign" width="16%">Image</td>
<td class="headingalign" width="16%">URL</td>
<td class="headingalign" width="05%"></td>
</tr>
</thead>
<tbody>
<tr id="id0" class="vals" name="row">
<td>
<div class="id_100">
<select type="select-one" id='fldsearch' class="objselect" name="fldsearch" onChange="disableField()" >
<option value="">Select</option>
<xsl:for-each select="faml/response/quicklinkresponsedto/searchby/datamapdto">
<xsl:sort order="ascending" select="description"/>
<option value="{datavalue}">
<xsl:value-of select="description"/>
</option>
</xsl:for-each>
</select>
</div> </td>
<td>
<input id="flddesc" name="flddesc" maxlength="500" disabled="true" class="objinputtext1" size="85" value="{//RESPONSE}" />
</td>
<td>
<input id="fldimg" name="fldimg" maxlength="50" disabled="true" class="objinputtext2" size="35" value="{//RESPONSE}" />
</td>
<td>
<input id="fldurl" name="fldurl" maxlength="15" disabled="true" class="objinputtext3" size="35" value="{//RESPONSE}" />
</td>
<td>
<input tabindex="6" value="Delete Row" disabled="true" class="DeleteButton" type="button" />
</td>
</tr>
</tbody>
</table>
<div class="buttonarea">
<ul>
<li><input tabindex="6" id="Button3" value="Add New Row" class="Buttons" name="Button3" type="button" /></li>
<li><input tabindex="6" id="Button5" value="Initiate" class="buttons" name="Button5" type="button" onclick="return fnOnSubmit();"/></li>
</ul>
</div>