텍스트 양식 필드 위에 텍스트를 오버레이하려고합니다. 텍스트는 포커스 이벤트가 발생할 때 텍스트 상자 위에 나타나야하고, 사용자가 실제로 문자를 입력 할 때까지 거기에 있어야합니다. 포커스가 발생하기 전에 이미 기본 텍스트가 있습니다.JQuery를 사용한 동적 양식 필드 오버레이
상자가 기본값으로 시작되고 초점이 맞춰지면 기본값이 사라지는 비슷한 유사점이 있지만이 경우에는 시도하지 않습니다.
내가 겪고있는 문제는 헬퍼 텍스트가 올바른 위치에 삽입되면, 특히 맨 위 및 왼쪽 CSS 속성을 동적으로 설정하는 것입니다.
내 onfocus 및 기능 :
TrueThis.OldValue = $('#MyField').val(); // Save the current value
$('#MyField').val(''); // Empty the text box
var OverlayHTML = '<div>This is helper text that goes on top.</div>'
// Insert the Overlay and position the top and left to match the parent
// PROBLEM:: The element is inserted, but is not positioned.
// No top and left css attributes were assigned according to Firebug.
$('#MyField').after(OverlayHTML).css({
'top':$('#MyField').position.top,
'left':$('#MyField').position.left
});
// Remove the overlay when a user starts typing.
$('#MyField').next().keyup(function(){this.remove();});
나는 문제는 내가 새로운 요소를 잡을 수 아니에요, 또는 전체 기능이 완료 될 때까지 아직 DOM에 존재하지 않는 가능성이 있다고 생각?