js this获取元素ID

Posted 沙弥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js this获取元素ID相关的知识,希望对你有一定的参考价值。

    <table id="cyyj_table" class="table01" cellpadding="5" cellspacing="1">
            <tbody id="tb">
             	<#list li as li>
             		<tr id=‘${li.id}‘>
             			<td width="80%">
             				<input id =‘${li.id}‘ class="customold" style="width:85%"  value=‘${li.custom}‘/>
             			</td>
             			<td align="center">
             				<input class="ordold" style="width:52px" type="number" value=‘${li.ord}‘/>
             			</td>
             			<td align="center">
             				<a class="zxui-linkbutton"  onclick="detCus(‘${li.id}‘);">删除</a>
             			</td>
             		</tr>
             	</#list>
            </tbody>
        </table>

js获取table两个input空间的值以及其id。

	$(".customold").each(function(){
		var customold = $(this).val();
		var obj = $(this);
		var customoldid = $(obj).attr(‘id‘);
		customolds+=customold+‘,‘;
		customoldids+=customoldid+‘,‘;
	});

 

以上是关于js this获取元素ID的主要内容,如果未能解决你的问题,请参考以下文章