js基础
来源:互联网 发布:留学cv 知乎 编辑:程序博客网 时间:2024/06/10 22:12
A.a标签的一些特殊功能1.<a href=#>刷新页面并回到顶部</a> 2.<a href="javascript:void(0)">只有标签效果,去除了a标签的自带的点击事件</a>3.<a href="javascript:;">同2相同</a>4.<a href="javascript:js代码;">点击执行js代码</a> js数据类型number string Boolean undefined null B. 透明度设置 css3 opacity: .5; filter: alpha(opacity:50); C.字符串拼接var h=500;var w=200;var bg="blue";document.write("<div style='width:"+w+"px;height:"+h+"px;background-color:"+bg+"'></div>")
D.
<table> <tr><th>总价</th> <th>数量</th><th>单价</th></tr> </thead> <tbody> <tr><td>1</td><td>1</td><td>1</td><td></td></tr> </tbody> </table>
table的标准格式 eg: var name=prompt("输入商品名称"); var number=parseInt(prompt("输入商品数量")); var price=parseFloat(prompt("输入商品价格")); document.write("<table>"); document.write("<thead>"); document.write("<tr><th>名称</th><th>数量</th><th>单价</th><th>应付金额</th></tr>"); document.write("</thead>"); document.write("<tbody>"); document.write(" <td>"+price+"</td><td>"+(number*+price)+"</td></tr>"); document.write("</tbody>");
E.
倒序输出数字,采用的取余的方式
eg:var num=parseInt(prompt(“请输入一个五位数”));
var g, s, b, q,w;
g=parseInt(num%10); ////////// 个位数的取余
s=parseInt(num%100/10);//12345—>45—>4.5—->4
b=parseInt(num%1000/100);
q=parseInt(num%10000/1000);
w=parseInt(num/10000);
document.write(num+”逆序输出为:”+g+s+b+q+w);
12345;
个位数 12345%10=1234*10+5;
十位数 12345%100/10=(123*100+45)/10 4.5 4
F.判断用户输入年份为闰年 还是平年
闰年:能被4整除但是不能被100整除或者是能被400整除的数
var aa=parseInt(prompt(“输入一个年份”));
var res=aa%4==0&&aa%100!==0||aa%100==0;
var res1=res?”瑞年” :”平年”
console.log(res1);
阅读全文
0 0
- js基础
- js基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- JS基础
- js基础
- js基础
- js基础
- js基础
- JS基础
- js 基础
- js-基础
- js基础
- js基础
- js基础
- mysql数据库增删查改操作命令
- Spring 基于注解的配置(一)(@Conmponent ,@Repository,@Service,以及对访问资源的限定)
- Codeforces Round #438 (Div. 1 + Div. 2 combined) D. Huge Strings
- 操作系统磁盘调度算法
- 设计模式笔记
- js基础
- cf_438_B
- Andrew-Coursera-DL课程-笔记part1-2(Shallow neural networks)
- codeforces 467B
- hadoop-企业版环境搭建(一)-环境搭建和hadoop基本配置
- C++函数重载机制及为什么要加extern C
- 设计模式-桥接模式
- Win7 + Vmware12 + Centos6.9 局域网环境NAT方式联网 附带 MySQL5.7安装
- Java实现二叉树