검색 할 단어를 입력하고 그 옆에있는 버튼을 클릭하는 용도로 사용되는 텍스트 상자가 있습니다.텍스트 상자에 포커스가있는 문제
<input id="EnterText" class="lightcolor" type="text" size="50" value="Enter text" maxlength="50" name="EnterText">
<input id="ClickButton" type="image" value="Button" name="ClickButton" onclick="" src="">
나는 좋은 사용자 경험 디자인을 생각하고 가서 포커스 이벤트가 발생했을 때 클래스를 변경하고 돌아올해야 밝은 색상에 텍스트 Enter text
를 입력 프런트 엔드에서 왔어요으로 할 때 흐림 이벤트가 발생합니다. 따라서 jQuery를 작성했습니다.
$(document).ready(function() {
$('#EnterText').focusin(function() {
alert("focus in");
var res = document.getElementById("EnterText");
document.getElementById("EnterText").value = "";
res.setAttribute("class", "afterClick");
});
$('#EnterText').focusout(function() {
alert("focus out");
var res = document.getElementById("EnterText");
document.getElementById("EnterText").value = "Enter Text";
res.setAttribute("class", "lightcolor");
});
$('ClickButton').click(function() {
alert("Click Button")
});
});
당신은 내가 focusin
, focus
, blur
및 focusout
을 시도,하지만 난이 focusout
이벤트가 트리거 버튼을 클릭하는 순간으로 필요한 일을 할 수없는 볼 수 있듯이. 사실 ClickButton
에 대한 경고는 절대로 표시되지 않습니다. 이 때문에 나는이 focusout
과 focusin
을 구현할 수 없으며 이제는 내 아이디어가 필요하게되었습니다. 나는 또한 텍스트 상자 포커스를 클릭하는 순간 이벤트가 먼저 호출 된 다음 포커스가 들어 왔음을 알았다. 필요한 모든 것은 텍스트를 사용자에게 안내해야하고 클릭 할 때 값을 입력하고 클릭하면된다. 이 버튼을 클릭하면 백엔드 사람들이 나머지를 처리하게됩니다.
안녕, 감사합니다. 티아고. 나는 그것들을 놓쳤다. 거기에 조건이 있고 나중에 내가 더 예쁘다. .. :) – NoviceCoder