将类文本转换为没有http和www的域名 [英] Transform class text to my domain name without http and www
本文介绍了将类文本转换为没有http和www的域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用jquery或任何脚本,如何将<header/>
上具有class ='site-title'的语义<p>
和<h1>
中的文本更改为没有http://
,www.
和永久链接路径的域名
Using jquery or any script, how to change Text inside semantic <p>
and <h1>
with class='site-title' on my <header/>
to my domain name without http://
, www.
and permalink path.
来源:
<header role='banner'>
<h1 class='site-title'>My Blog Title</h1><!-- homepage header title -->
<p class='site-title'><a href='mylink'>My Blog Title</a></p><!-- other page header title -->
</header>
TO (如果博客使用的是子域):
TO (if blog is using sub-domain):
<header role='banner'>
<h1 class='site-title'>mysubdomain.blogspot.com</h1><!-- change the text My Blog Title only -->
<p class='site-title'><a href='mylink'>mysubdomain.blogspot.com</a></p><!-- get my domain name witout http and www -->
</header>
OR (如果博客使用自身域-而非子域):
OR (if blog using self domain - not sub-domain):
<header role='banner'>
<h1 class='site-title'>blogspot.com</h1>
<p class='site-title' href='mylink'>blogspot.com</p>
</header>
推荐答案
尝试一下:
$(document).ready(function () {
$('.site-title').text(window.location.host);
});
将h1和p的文本替换为页面的当前网址.
Where the text of h1 and p will be replaced by the current url of the page.
这篇关于将类文本转换为没有http和www的域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文