HTML里面怎么设计做一个加减乘除的网页
导读:本文共1404字符,通常情况下阅读需要5分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要:这个需要知道javascript,这方面语言会吗?不会的话,帮你写一个了!123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<!DOCTYPEhtml><html><head><metacharset="utf-8"... ...
目录
(为您整理了一些要点),点击可以直达。这个需要知道javascript,这方面语言会吗?不会的话,帮你写一个了!123456789101112131415161718192021222324252627282930313233343536373839404142434445464748<!DOCTYPEhtml><html><head><metacharset="utf-8"/><title>计算器</title></head><scriptsrc="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script><scripttype="text/javascript">$(function(){$("button").click(function(){varfirst=parseInt($("#first").val());//获取第一个数的值并转化为数字varsecond=parseInt($("#second").val());//获取第二个数的值并转化为数字varsum=0;//定义结果值varsymbol=parseInt($("[type=radio]:checked").val());//获取符号的值//通过对符号的判断计算结果switch(symbol){case0:sum=first+second;break;case1:sum=first-second;break;case2:sum=first*second;break;case3:sum=first/second;break;}vararr=['+','-','*','/'];//输出的符号$("h2span").text(first+arr[symbol]+second+"="+sum);//把结果输出到结果栏中}) })</script><body><h1>计算器</h1><p>数字一:<inputtype="text"id="first"style="width:40px;"/></p><p><label><inputtype="radio"name="symbol"value="0"checked="checked"/>+</label><label><inputtype="radio"name="symbol"value="1"/>-</label><label><inputtype="radio"name="symbol"value="2"/>*</label><label><inputtype="radio"name="symbol"value="3"/>/</label></p><p>数字二:<inputtype="text"id="second"style="width:40px;"/></p><p><button>计算</button></p><h2>结果:<span></span></h2></body></html>
HTML里面怎么设计做一个加减乘除的网页的详细内容,希望对您有所帮助,信息来源于网络。