Hi to all! Can someone please tell me and knows how to grab page title and post that title to the same page?? I have basic HTML but can't find the solution. Thanks!
Display title of the web page as a content in the same page inside, when refresh each page has a different title name I want to grab that page title and display as a page content
If I understand well what you need to do then it depends if you are using a CMS like wordpress then you can do it with built in functions of the CMS however you can do this with javascript too. I wrote a small jQuery script that will help you to do this:
Code:
$(document).ready(function() {
var titlename = document.title;
var myelement = $("<h2></h2>").text(titlename);
$("#div1").append(myelement);
return this;
});
In this case what I did was to create an h2 element and add it inside the div element with id div1. You can change this to whatever your element id is and whatever type of element you want to create, don't forget to add the jQuery CDN so that your script can work. Let me know if this is confusing or need more help understanding what you need to do.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.