I want to display a div tag as Webpage Title
Suppose my div tag
<div id="songArtist"></div>
has a content of "Akon" then my title of page should be Akon
Adding div tag between this <title></title>
is not working
Please help me..
I want to display a div tag as Webpage Title
Suppose my div tag
<div id="songArtist"></div>
has a content of "Akon" then my title of page should be Akon
Adding div tag between this <title></title>
is not working
Please help me..
Check this -
Instead of Random Title it will show div content(Akon in this case).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Random Title</title>
</head>
<body>
<div id="songArtist">Akon</div>
<script>
document.title = document.getElementById("songArtist").innerHTML;
</script>
</body>
</html>
After any call to the function, object, request that changes the content of
<div id="songArtist"></div>
dynamically, you can then call the below in Javascript;
doocument.title = document.getElementById('songArtist').innerHTML;
Try this:
$(document).ready( function() {
document.title = $('#songArtist').text();
});
If you want it to change on every change occurring to this div
then you'd use:
$(document).ready( function() {
$('div').on( '#songArtist', 'change', function() {
document.title = $(this).text();
});
});
You can change the title like this
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>hi</title>
</head>
<body>
<div id='songArtist'> Welcome to this page </div>
<script language="javascript" >
document.title= document.getElementById('songArtist').innerHTML;
</script>
</body>
</html>
` tag.
– James Donnelly May 01 '13 at 08:21With PHP
<html>
<head>
<title><?php echo $page_title;?></title>
</head>
</html>
Static title.
<html>
<head>
<title>
Akon
</title>
</head>
</html>