新聞中心
javascript 我做好了一個javascript的文件,但是老師說讓改寫幾個地方,實在不會了··
你看下行不行!
三亞網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站開發(fā)等網(wǎng)站項目制作,到程序開發(fā),運營維護。成都創(chuàng)新互聯(lián)自2013年起到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /
titleThe Baseball Diamond Calculator/title
script language="javascript"
var length,diameter,circleArea,grassArea,allLength;
//circleArea : The area of each circle
//grassArea : The area of the grass field
//allLength : The length of all basepaths
function count(){
length = window.prompt("Enter length of basepaths in feet:","");
if(isNaN(length)||length0){
alert('長度必須為大于零的數(shù)!');
return count();
}
diameter = window.prompt("Enter diameter of all circles in feet:","");
if(isNaN(diameter)||diameter0){
alert('請輸入大于零的數(shù)');
return count();
}
circleArea = Math.pow(diameter * 0.5,2) * Math.PI;
grassArea = Math.pow(length,2) - circleArea * 2;
allLength = length * 4;
document.write("For the baseball diamond with "+length+" ft base paths and circles with diameter of "+diameter+" ftbr /br /");
document.write("The area of each circle is "+circleArea+" ft2br /");
document.write("The area of all five circle is "+circleArea * 5+" ft2br /");
document.write("And the area of the grass field is "+grassArea+" ft2br /");
document.write("The length of all basepaths is "+allLength+" ftbr /");
}
/script
/head
body onload="count();"
/body
/html
javascript有沒有什么比賽
有啊,國外有1KB JS比賽,
就是你的js最大1kb,但是運行后的看誰的效果非常炫,或者cool。
還有個比賽的21行代碼,你的代碼最多21行(不是壓縮后的那種),然后看誰的效果更cool。
國外人對所有cool的東西都非常熱情。而且我們大多數(shù)是為了生計,知道這樣做有什么意義。
js全選,反選,全不選
首先選擇器寫法就不對
document.getElementsByName['game'],至少這么寫
其次
由于你所有input標簽所有的name屬性都不一樣,不能批量選擇,除非像樓上貼代碼那哥們一樣,把所有的復(fù)選框的name屬性都改為game也可以。如果純粹是為了達到目的話用document.getElementsByTagName("input"),能達到效果
另外,樓上也提到了,判斷的等號==
還有提醒樓主一下,不要反復(fù)的使用選擇器,少量代碼無所謂,大量代碼的情況下會降低運算效率的。
在樓主的代碼基礎(chǔ)上改了一下
//全選
function?test()
{
??obj?=?document.getElementsByTagName("input")
for(var?i=0;iobj.length-3;i++)
{
var?f=obj[i];
if(f.checked==false)
{
f.checked=true;
}
}
}
//反選
function?ftest()
{
obj?=?document.getElementsByTagName("input")
for(?var?i=0;iobj.length-3;i++)
{
f=obj[i];
if(f.checked==false)
{
f.checked=true;
}
else
{
f.checked=false;
}
}
}
//全部取消
function?CancelAll()
{
obj?=?document.getElementsByTagName("input")
for(?var?i=0;iobj.length-3;i++)
{
f=obj[i];
if(f.checked==true)
{
f.checked=false;
}
}
}
分享題目:包含javascript棒球比賽的詞條
網(wǎng)頁URL:http://fisionsoft.com.cn/article/dsdcgci.html