jQuery: how to change title of document during .ready()?

前端 未结 8 1861
逝去的感伤
逝去的感伤 2020-11-27 12:37

I am using some nested layouts in Ruby on Rails, and in one of the layouts i have a need to read in a string from a div and set that as the title of the document. What is co

8条回答
  •  Happy的楠姐
    2020-11-27 13:12

    If you have got a serverside script get_title.php that echoes the current title session this works fine in jQuery:

    $.get('get_title.php',function(*respons*){
        title=*respons* + 'whatever you want'   
        $(document).attr('title',title)
    })
    

提交回复
热议问题