我有这个jQuery代码。我在这里以第一行作为评论,因为它们在我的问题中并不重要,仅仅用于结构。我点击事件后,点击td我有输入字段中的文字。我将重点放在文字的末尾。但是当我点击鼠标时,我想删除焦点,这样我可以点击名称的中间位置,光标就会在那里。当它是一个('点击')时它会工作,但我需要多次执行,因此一次点击只能执行一次。one。('click')reset点击后
$('td').on('click', function() {
//val = $(this).text();
//console.log(val);
//rowid = $(this).parents('tr').attr('id');
//realclass = $(this).attr('class');
//$("tr").filter("#" + rowid).find("td").filter("." + realclass).find("span").hide(); //hide td->span field..
//$("tr").filter("#" + rowid).find("td").filter("." + realclass).find("input").show();//..and show input field
//get focus on end of input val
SearchInput = $("tr").filter("#" + rowid).find("td").filter("." + realclass).find("input");
strLength = SearchInput.val().length;
SearchInput.focus();
SearchInput[0].setSelectionRange(strLength, strLength);
});
你能设置一个的jsfiddle重现呢? http://jsfiddle.net/ – RononDex
'$(“tr”)。filter(“#”+ rowid)''可以只是'$(“#”+ rowid)' – Pete
是的。我也错过了。 – user3316619