0

现在悬停菜单隐藏,搜索框展开以填充菜单。如何将焦点添加到搜索框并在此悬停事件上插入闪烁的插入符号并在悬停退出时将其删除?

<body>
    <input type="text" value="" id="search" class="noquery" />
</body>

<script>
    $(function(){
        $("#search").hover(function(){
            $("#navi1 ul").hide();
            $("#search").css("width","100%");
            },function(){
            $("#navi1 ul").show();
            $("#search").css("width","96px");
            });
        });
</script>
4

1 回答 1

2

尝试这个:

$(function () {
    $("#search").hover(function () {
        $("#navi1 ul").hide();
        $("#search").css("width", "100%");
        $(this).focus(); // to focus
    }, function () {
        $("#navi1 ul").show();
        $("#search").css("width", "96px");
        $(this).blur().val('');  //to remove focus (blur)
    });
});

演示在这里

于 2013-09-08T18:32:55.167 回答