javascript:如何删除标题上的元素 [英] javascript: how to remove element on title
本文介绍了javascript:如何删除标题上的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这听起来很奇怪,但是目前我正在使用一个CMS模板,并且标题围绕着标题
标题>< div id =title>页面的标题< / div>< / title>
解决方案
$(title)。text($(< div / > 中。)HTML($( 标题)文本())文本())。;
将原始标题标签的(不当)HTML文本存储到临时div中,然后放置 - 临时div的文本内容返回标题。
编辑:可能是更好的解决方案,适用于IE6:
document.title = $(< div />).html(document.title).text();
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();
这篇关于javascript:如何删除标题上的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文