我有這個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