I have two text boxes and the focus effect only works in the first one. I want the text to be deleted when the mouse focuses on the text box.
.header-text-box {
margin: 65px 0 0 160px;
height: 38px;
width: 200px;
background-color: #e6e7e9;
}
.header-text-box-2 {
margin: 65px 0 0 60px;
height: 38px;
width: 200px;
background-color: #e6e7e9;
}
mtf
#2
If you give both text boxes a common ancestor, then you can use delegation of the event handler by registering a listener on the ancestor.
Say you have a container with class “textbox-container”,
$('.textbox-container').on('focus', 'textarea', function () {
$(this).val('');
});
system
closed
#3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.