Home Web Front-end JS Tutorial JavaScript custom function parameters are passed in string format_javascript tips

JavaScript custom function parameters are passed in string format_javascript tips

May 16, 2016 pm 04:40 PM
Parameter passing Custom function

The custom function parameters are passed in string format and the transmission method is
1: Pass this with
2: Quotes are defaulted
3: Escape characters (" in HTML represents "double quotation mark, ' represents single quotation mark, in JavaScript directly "" and Java universal escape character set)

<html> 
<head> 
<script language="LiveScript"> 
function print(arg){ 
alert("你好!"+arg); 
} 
</script> 
</head> 
<body> 
<form> 
<input type="button" name="Button1" value="first" onclick="print(this.str)" str="你好one"> 
<br><br> 
<input type="button" name="button2" value="second" onclick=print("你好two")> 

<br><br> 
<input type="button" name="button3" value="Third" onclick="print (&quot你好three&quot)"> 

</form> 
</body> 
</html>
Copy after login
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Best practices for optimizing Golang function parameter passing performance Best practices for optimizing Golang function parameter passing performance Apr 13, 2024 am 11:15 AM

Best practices for optimizing Golang function parameter passing performance

In-depth analysis of the declaration and call of JS custom functions In-depth analysis of the declaration and call of JS custom functions Aug 03, 2022 pm 07:28 PM

In-depth analysis of the declaration and call of JS custom functions

Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming Apr 27, 2024 pm 02:09 PM

Detailed explanation of C++ function parameters: Performance optimization of parameter passing in parallel programming

Research on parameter passing methods in Go language Research on parameter passing methods in Go language Apr 03, 2024 pm 02:48 PM

Research on parameter passing methods in Go language

How to write custom functions in MySQL using Python How to write custom functions in MySQL using Python Sep 22, 2023 am 08:00 AM

How to write custom functions in MySQL using Python

C++ function pointer parameter passing mechanism C++ function pointer parameter passing mechanism Apr 19, 2024 pm 02:06 PM

C++ function pointer parameter passing mechanism

golang function map passed as parameter golang function map passed as parameter Apr 22, 2024 am 11:42 AM

golang function map passed as parameter

Creation of PHP user-defined functions Creation of PHP user-defined functions Apr 14, 2024 am 09:18 AM

Creation of PHP user-defined functions

See all articles