Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Head Title value using jquery

Tags:

jquery

i have html page and i want head title value on page load using jquery, see my below html code

<html>
<head>`enter code here`
<title>Home - chcc</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
</head>


<input type='button' value='find div .A1' id='button1'>

</body>
</html>
like image 978
kalpesh Avatar asked Mar 29 '12 10:03

kalpesh


3 Answers

You don't even need jQuery for this. Just use the document.title property

like image 73
poncha Avatar answered Nov 16 '22 18:11

poncha


If you want jQuery instead raw javascript, use $("head title")[0];

like image 7
gabitzish Avatar answered Nov 16 '22 18:11

gabitzish


You can select the Title tag by using only Javascript like the Following:

var title = document.getElementsByTagName("title")[0].innerHTML;
// Then you can print it on the screen
alert(title);
like image 1
hamdev Avatar answered Nov 16 '22 17:11

hamdev