焦点触发与离开事件(focus与blur)

<input name="pressTimes" id="pressTimes" type="text" style="width:30px; text-align:right;"  maxlength="2" value="">
<table id="TableHead" class="tableStyle cutInfoSetTable" style="width:1300px" cellspacing="0" cellpadding="0">
	<thead>
		<tr class="firstTr">
			<td class="tdTitle">No</td>
			<td class="tdTitle">名称</td>
			<td class="tdTitle">CD</td>
			<td class="tdTitle">計画No</td>
			<td class="tdTitle" colspan="2">数量</td>
			<td class="tdTitle">地址</td>
			<td class="tdTitle">负责人</td>
		</tr>
	</thead>
	<tbody >
		<tr  th:each="item : ${objectList}">
			<td class="tdText"><a class="cutInfoSet_No" th:title="${item.No}" th:text="${item.No}"></a></td>
			<td class="tdText"><nobr><a class="cutInfoSet_Nm" th:title="${item.Nm}" th:text="${item.Nm}"></a></nobr></td>
			<td class="tdText"><a class="cutInfoSet_Cd" th:title="${item.Cd}" th:text="${item.Cd}"></a></td>
			<td class="tdText"><a class="cutInfoSet_JHNo" th:title="${item.JHNo}" th:text="${item.JHNo}"></a></td>
			<td class="tdText numberStyle"><input class="cutInfoSet_qty" th:title="${item.qty}" th:text="${item.qty}"></input></td>
			<td class="tdText"><a class="cutInfoSet_unit" th:title="${item.unit}" th:text="${item.unit}"></a></td>
			<td class="tdText"><nobr><a class="cutInfoSet_addr" th:data-addr="${item.addr}" th:title="${item.addr}" th:text="${item.addr}"></a></nobr></td>
			<td class="tdText"><a class="cutInfoSet_FZR" th:title="${item.FZR}" th:text="${item.FZR}"></a></td>
		</tr>
	</tbody>
</table>

设置焦点:

$('#pressTimes').focus();

一、焦点点击事件:

第一种:

$('.cutInfoSet_qty').focus(function(){
         ...
    });

第二种(注意:有次$('')中放的不是body,好像不起作用,不知为何,有知道的,告知一下):

$('body').on('focus','.cutInfoSet_qty', function(){
        $(this).closest("#TableHead").scrollLeft(0); ...
    });


二、焦点离开事件:

$('.cutInfoSet_qty').blur(function() {
        $(this).val($(this).val().replace(/,/g,''));
        ...
});

或者

$('#XXXX').on("blur",function(){
       var qty_data = $(this).val();
}) 

或者

$('body').on('blur', '.cutInfoSet_qty', function(){
        var qty_data = $(this).val();
        ...
})

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值