0

I want to alter the title tag in jquery. tried as $(document).attr("title", "New Title"); but title tag in view source is not altered and changed only in browser title bar.

How to change the title in title tag in jquery

new title

user3386779
  • 5,675
  • 12
  • 49
  • 109

1 Answers1

0

This can be done by this

$(document).ready(function() {
        document.title = 'blah';
});
Kevin
  • 940
  • 3
  • 17
  • It's working the same as OP's approach.. – Mosh Feu Jan 21 '20 at 11:31
  • There's no need for a document.ready handler for this – Rory McCrossan Jan 21 '20 at 11:33
  • I wonder why you would say that. jQuery aim to be cross platform (except very old browsers?), isn't? @RoryMcCrossan. I couldn't find an official answer but found [this](https://stackoverflow.com/a/4989558/863110) – Mosh Feu Jan 21 '20 at 11:40
  • I've deleted the comment already, but I didn't expect using `attr('title')` to do anything as `title` is a property of `document`, not an attribute. I assumed this was a browser implementation playing nice and making the conversion for you, but maybe jQuery does it instead. – Rory McCrossan Jan 21 '20 at 11:42