gpt4 book ai didi

jquery - 如果文本框未激活 jquery 则替换 div

转载 作者:行者123 更新时间:2023-12-01 03:14:59 25 4
gpt4 key购买 nike

我不知道如何检查框中是否有光标。如果文本框为空或未激活,我想替换 div。

.js.erb 文件

if($('#headersearch').val().trim() ==  "") {
$("#header_user_list").html('');}
else if(!$('#headersearch').is(":focus")){ <-- this line isnt working
$("#header_user_list").html('');}
else{$("#header_user_list").html('<%= j render @header_users %>')}

最佳答案

您可以使用focusout - documentation here .

关于jquery - 如果文本框未激活 jquery 则替换 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17543564/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com