阅读:4123回复:0
JS实现奇偶数的判断
<html xmlns="http://www.w3.org/1999/xhtml" >
<head> <title>标题页-学无忧(www.xue51.com)</title> <Script language="JavaScript" type="text/javascript"> function chk(num){ alert( (num%2 ==0) ?"偶数":"奇数"); //判断是否能整除2 } </Script> </head> <body> <input type=text name="txt1" value="4"> <input type=button value="判断" onClick="chk(txt1.value)"> </body> </html> |
|