Home > Web Front-end > JS Tutorial > body text

javascript anchor() 方法创建 HTML 锚

WBOY
Release: 2016-06-01 09:54:38
Original
1641 people have browsed it

anchor 方法在对象中的指定文本两端放置一个有 NAME 属性的 HTML 锚点。

基本语法:

<code class="language-javascript">strVariable.anchor(anchorString)</code>
Copy after login

参数介绍

参数 描述
anchorString 必需。想放在 HTML 锚点的 NAME 属性中的文本。

实例:

调用 anchor 方法来在 String 对象外创建一个命名的锚点。

下面示例说明了 anchor 方法是如何实现这个的:

<code class="language-javascript"><script type="text/javascript">
var strVariable = "This is an anchor" ;
strVariable = strVariable.anchor("Anchor1");
alert(strVariable);
</script></code>
Copy after login

在线运行

执行完最后一条语句后 strVariable 的值为:

<code class="language-html"><a name="Anchor1">This is an anchor</a></code>
Copy after login

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!