开发者

Adding title to page with instant jQuery search script

开发者 https://www.devze.com 2023-03-10 06:21 出处:网络
I have a Google Instant style search script written in jQuery. When the user queries, #SEARCHTERM is added onto my page URL. I was wondering how I could add the users query into the title of my page s

I have a Google Instant style search script written in jQuery. When the user queries, #SEARCHTERM is added onto my page URL. I was wondering how I could add the users query into the title of my page so it would be "SEARCHTERM - My Search Script"

Here is my current code:

$(document).ready(function(){
    $("#search").keyup(function(){
        var search=$(this).val();
        var keyword=encodeURIComponent(search);
        var yt_url='search.php开发者_如何学JAVA?q='+keyword+'&category=web';
        window.location.hash=keyword;

        $.ajax({
            type:"GET",
            url:yt_url,
            dataType:"html",
            success:function(response){
                $("#result").html(response);
            }
        });
    });
});


Assign title with: document.title

document.title = $(this).val() + " - My Search Script";
0

精彩评论

暂无评论...
验证码 换一张
取 消