Javascript custom function arguments are passed in string format

  • 2020-03-30 03:38:23
  • OfStack

Custom function parameters are passed as a string format, passing way
1: use this to pass
2: quote default
3: escape characters (in HTML & Quot; "Double quotation marks, & Apos; Single quotes, direct \" in javascript and Java universal escape character set)


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

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

</form> 
</body> 
</html>

Related articles: