javascript:如何删除标题上的元素
作为标题,如何使用javascript或jquery框架删除html标题上的div? 我知道这听起来很奇怪,但目前我正在研究一个CMS模板,并且生成标题有标题
Title of the page
任何帮助赞赏
$("title").text($("").html($("title").text()).text());
将原始标题标记的(不适当的)HTML文本存储到临时div中,然后将临时div的纯文本内容放回标题中。
编辑:可能是一个适用于IE6的更好的解决方案:
document.title = $("").html(document.title).text();
做:
// 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, "" );
var title = document.getElementsByTagName("title")[0]; title.innerHTML = title.firstChild.innerHTML;
或
var title = document.getElementById("title"); title.parentNode.removeChild(title);