html标签内部,简单加js
<a href=""></a><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>html标签内部,简单加js</title> <meta name="keywords" content="关键字列表" /> <meta name="description" content="网页描述" /> <link rel="stylesheet" type="text/css" href="" /> <style type="text/css"></style> <script type="text/javascript"> var i = "http://www.w3school.com.cn"; var str = "<div>"; str +='<a href="'+i+'">W3School</a>'; str +="</div>"; document.write(str); </script> </head> <body> </body> </html>
一维数组求最大值,最小值两个值位置demo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>网页标题</title> <meta name="keywords" content="关键字列表" /> <meta name="description" content="网页描述" /> <link rel="stylesheet" type="text/css" href="" /> <style type="text/css"></style> <script type="text/javascript"> var arr=[10,56,78,43,34,67,4] function getMax(arr2){ var max=arr2[0]; var min=arr2[0]; var maxwz=0; var minwz=0;
for(var i=0;i<arr2.length;i++){ if(max<arr[i]){ max=arr[i]; maxwz=i } if(min>arr[i]){ min=arr[i]; minwz=i } } document.write("最大"+max); document.write("最大值得位置:"+maxwz); document.write("<hr>") document.write("最小"+min); document.write("最小值得位置:"+minwz); } getMax(arr) </script> </head> <body> </body> </html>
数字金字塔demo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>网页标题</title> <meta name="keywords" content="关键字列表" /> <meta name="description" content="网页描述" /> <link rel="stylesheet" type="text/css" href="" /> <style type="text/css"></style> <script type="text/javascript"> function txbg(m){
//控制最大数,自行修改 if(m>9){ m=9; }
//控制最小数 if(m<2){ m=2; }
//倒序金字塔(9-2) for(var a=m;a>1;a--){ for(var b=1;b<=a;b++){ document.write(a) } document.write("<br/>") } //金字塔(1-9) for(var a=1;a<=m;a++){ for(var b=1;b<=a;b++){ document.write(a) } document.write("<br/>") } }
//传参输出图形 txbg(20); </script> </head> <body> </body> </html>