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

WBOY
Release: 2016-05-16 16:40:56
Original
1584 people have browsed it

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