Article From:https://segmentfault.com/q/1010000011712239
Question:

For example, when you do a search box, you are required to click the button to clear the contents of the input, but when you click the button, the input will lose focus. How can you make it not lose focus, that is, you want to make it look like this
Clear the content when you click that x.

Additionally, I did this as if the click event didn’t go in because I didn’t get alert.
I don’t know what this is.
<form action=”” class=”act_search”>

    <input id="search_title"  type="text" value="Activity "/>< P class= "close_btn" id= "BTN" >< B class= "search-close" > < /b>< /p>< /form>

//Empty search

    $('.close_btn').click(function(){
        alert('1');
        $(this).hide();
        $('#search_title').focus();
        $('#search_title').val('');
    });

Answer 0:

After losing focus, will it not be enough to focus on it?

Supplement:
No access to alert is that click is not invoked. Look at the style of the B tag.

Answer 1:

xSet a ID, assuming that x is here, and the ID of input is text.

$(“#x”).click(function(){

$("#text").val("");
$("#text").focus();

});

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *