1. 程式人生 > >js this獲取元素ID

js this獲取元素ID

div clas pad style spa each width class adding

    <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