Home  >  Article  >  Web Front-end  >  Getting started with the JavaScript link method (adding a hyperlink to a string)_Basic knowledge

Getting started with the JavaScript link method (adding a hyperlink to a string)_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:33:301659browse

The

link method returns a (italicized) string defined using the HTML a tag attribute. Its syntax is as follows:

Copy code The code is as follows:

str_object.link( url )

Parameter description:

参数 说明
str_object 要操作的字符串(对象)
url 必需。字符串要链接的 URL 地址,完整格式。

Tip: This method does not comply with ECMA standards and is not recommended.

link method instance

Copy code The code is as follows:


Run this example, output:

Copy code The code is as follows:

Tip: This method returns the hyperlink string defined using the HTML a tag, even though this method cannot directly change the string into a hyperlink string. If you want to dynamically change the element font to a hyperlink string, you can refer to the following example to extend the link method:

Change the font of page elements to hyperlinks

Copy code The code is as follows:



www.jb51.net




In this example, double-click the string www.jb51.net to add a hyperlink to the string.

Statement:
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