As the title, how can I remove a div on the html title using javascript or jquery framework?
I know it sounds weird but currently I'm working on a CMS template and the generate title has around the title
<title><div id="title">Title of the page</div></title>
Any help appreciated
$("title").text($("<div/>").html($("title").text()).text());
Stores the (inappropriate) HTML text of the original title tag into a temporary div, then puts the plain-text content of the temporary div back into the title.
EDIT: Probably a better solution that works on IE6 as well:
document.title = $("<div/>").html(document.title).text();
Do:
// get the title from the div and apply to the title tag and then remove div
$('div#title').parent().html($(this).text()).remove();
var tag = /(\<.*?\>)/g;
document.title = document.title.replace( tag, "" );
<title>Title of the page</title>
to strip the div tags
var title = document.getElementsByTagName("title")[0];
title.innerHTML = title.firstChild.innerHTML;
or <title></title>
If you want to remove the whole div
var title = document.getElementById("title");
title.parentNode.removeChild(title);