javascript+HTML+CSS面试题

今天参加面试,考了我三个小时,考晕了,赶紧补习补习javascript的知识!(另:人事部明明说招HTML5+CSS3+jQuery,考1个半小时左右,怎么变成了考传统DIV+CSS+javascript啦,呜呜呜~~~)

先看看简单的

1、完成foo()函数的内容,要求能够弹出对话框提示当前选中的是第几个单选框。

<html> 
<head> 
<script> 
function foo() 
{ 
// 在此处添加代码 var rg = document.getElementsByName("radioGroup"); for( var i = 0; i < rg.length; i++ ) { if( rg[i].checked ) {  alert("你选择了第" + (i+1) + "个单选框"); } } return false; 
} 
</script> 
</head> 
<body> 
<form name="form1" οnsubmit="return foo();"> <input type="radio" name="radioGroup" /> <input type="radio" name="radioGroup" /> <input type="radio" name="radioGroup" /> <input type="radio" name="radioGroup" /> <input type="radio" name="radioGroup" /> <input type="radio" name="radioGroup" /> <input type="submit" /> 
</form> 
</body> 
</html>

2、完成字符串翻转功能 填充注释部分的函数体,使得foo()函数调用弹出”成功”的对话框。

<html> 
<head> 
<script> 
function foo() 
{ var str = reverse('a,b,c,d,e,f,g'); alert(str); if (str == 'g,f,e,d,c,b,a') alert('成功'); else alert('失败'); } 
function reverse(str) { // 在此处加入代码,完成字符串翻转功能 var spl = str.split(','); var newstr=""; for(i=spl.length-1;i>=0;i--) { newstr+=spl[i]+','; } newstr=newstr.substring(0,newstr.length-1) return newstr; } </script> </head> <body> <input type="button" value="str" οnclick="foo()" /> </body> </html>

3. 有一组数字,从1到n,从中减少了3个数,顺序也被打乱,放在一个n-3的数组里请找出丢失的数字,最好能有程序,最好算法比较快

<script type="text/javascript">
//<!--var oldArr = [0,1, 2, 3, 4, 5, 6, 7, 8, 9]; //初始数组var newArr = [5, 6, 3, 9, 0, 8, 2]; //去掉 1 4 7三个数字并且顺序是乱的 var lostArr = []; //要找的数的数组newArr.sort(); //排序var newString = ',' + newArr.join(',') + ',';var length = oldArr.length;for (var j = 0; j < length; j++) {var oldString = ',' + oldArr[j] + ',';if (newString.indexOf(oldString)==-1)lostArr.push(oldArr[j]);}alert(lostArr);
//-->
</script>

只用一次循环

<script>var a = [0,3,4,8,9,2,6];var b = [];var i, len, min, max;a.sort(function (a, b) {return a-b;});for (i=0,len=a.length;i<len;i+=1) {min = a[i];max = a[i+1]if (max !== min + 1) {b.push(min+1);}}alert(b.slice(0,-1));
</script> 

4、编写一个测试页面,第一道题答对后显示第二道题,如果答错给出正确答案后再显示第二道题,依次类推,当三道题全部答对后给出提示:"恭喜,你全部答对了!"

如:第一题:你的姓名?

      选项: A 管理员(正确答案)  B 游客  C 无名

      第二题:你所在的公司名称?

      选项: A IBM  B Oracle  C BIG(正确答案)

      ...

5.标签页导航效果

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>   
<title>自适应宽度的标签导航</title>  
<META http-equiv=Content-Type content="text/html; charset=gb2312">  <STYLE type=text/css>
*{margin:0px;padding:0px;}
.tab{ 
border:1px solid #FF0000;
width:296px;  
margin:0px auto; 
}
.menu{font-size:12px}
.menu ul li{ 
text-align:center; 
display:block; 
float:left; 
height:25px; 
width:98px; 
line-height:25px; 
cursor:pointer; 
background:#ddd;
border-right-width:1px; 
border-bottom-width:1px; 
border-right-style:solid; 
border-bottom-style:solid; 
border-right-color:#FF0000; 
border-bottom-color:#FF0000;
}
.menu ul li.tabhover{ 
border-bottom-style:none; 
font-weight:bold; color:#FF0000;
background:#fff;
}
.ctn{ 
padding-top:40px; 
padding-bottom:20px; 
padding-left:10px;}
.cle{ clear:both; height:0px;}
</STYLE>  <META content="MSHTML 6.00.2800.1589" name=GENERATOR></HEAD>  
<BODY>  <div class="tab"><div class="menu"><ul><li id="m1" onmouseover="gettab(1)" class="tabhover">标题一</li><li id="m2" onmouseover="gettab(2)">标题二</li><li id="m3" style="border-right:none" onmouseover="gettab(3)">标题三</li>    </ul></div><div class="cle"></div><div class="ctn"><div id="c1">此处显示一的内容</div><div id="c2" style="display:none">此处显示二的内容</div><div id="c3" style="display:none">此处显示三的内容</div></div></div><div class="tab"><p>注意:<br>tab与li的宽度设置:98*3+2=296</p>
</div><script type="text/javascript">function gettab(i) {for (n = 1; n <= 3; n++) {var m = document.getElementById("m" + n);var c = document.getElementById("c" + n);m.className = (n == i) ? "tabhover": "";c.style.display = (n == i) ? "block": "none";}}
</script></BODY></HTML>

 

6、HTML+CSS题。布置如下页面(logo图片我用了我自己的,O(∩_∩)O)

HTML部分

<div class="top"><div class="logo"><img src="my.jpg" /></div><div class="topmenu"><ul><li>menu 1</li><li>menu 2</li><li>menu 3</li></ul></div>
</div>
<div class="mainSection"><div class="leftmenu"><ul><li>menu 1</li><li>menu 2</li><li>menu 3</li></ul>            </div>    <div class="section"><div class="aside"><div class="text"><p>section 2s2section 2section 2section 2section 2section 2section 2section 2section 2sectection 2section 2section 2section 2section 2section 2section 2section 2section 2</p></div></div><div class="text"><h2>section 1</h2>        <p>section 1sectio2section 2section 2section 2section 2section 2section 2section 2section 2sectn 1section 1section 1section 1section 1section 1section 1section 1section 1section 1</p><h2>section 2</h2><p>section 2section 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2section 2</p><h2>section 3</h2><p>section 2section 2n 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sen 2section 2section 2section 2section 2section 2section 2section 2section 2sect2section 2section 2section 2section 2section 2section 2section 2sesection 2section 2section 2section 2section 2section 2section 2section 2section 2</p></div></div><div style="clear:both"></div> 
</div>
<div class="footer">footer</div>

其中,

1)text div是用来让显示内容和其他box之间产生间隙的

2) 最后的空<div style="clear:both"></div>用来消除3px的bug,是footer紧接着mainSection布局

CSS部分

*{margin:0px;border:0px;padding:0px;}
.top{margin:0 auto;    //居中width:950px;border:1px solid blue;margin-top:10px;
}
.logo{padding:10px;
}
.topmenu{margin-left:180px;
}
.topmenu ul li{display:inline-block;list-style:none;padding:5px;background:blue;
}
.mainSection{margin:0 auto;width:950px;border:1px solid blue;border-top:0px;background:blue;
}
.leftmenu{float:left;width:180px;    //注意:section和leftmenu的width必须同时给出,不然布局会变形
}
.leftmenu ul li{color:white;list-style:none;padding:5px;
}
.section{background:white;float:left;width:770px;   //注意:原因慢慢去找
}
.aside{float:right;width:300px;height:200px;clear:left;    //使得section能环绕aside
}
.footer{clear:both;    //清除默认布局margin:0 auto;text-align:center;background:#ccc;width:950px;height:40px;border:1px solid blue;border-top:0px;
}
.text{padding:15px;} 

转载于:https://www.cnblogs.com/JoannaQ/archive/2012/08/30/2663040.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/251522.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

android 对话框

android 8种对话框&#xff08;Dialog&#xff09;使用方法汇总 作者&#xff1a;gzdaijie本文为作者原创&#xff0c;转载请注明出处&#xff1a;https://www.cnblogs.com/gzdaijie/p/5222191.html 目录 1.写在前面2.代码示例2.1 普通Dialog&#xff08;图1与图2&#xff09;2…

Java 多线程 之 suspend挂起 线程实例

http://www.verejava.com/?id16992945731073 package com.suspend.resume; /*题目: 人们在火车站的售票窗口排队买火车票1. 北京西站开门2. 打开售票窗口3. 北京西站有10张去长沙的票4. 打开2个售票窗口, 5 假设每个售票窗口每隔1秒钟买完一张票1. 根据 名词 找类人们(Person…

算法 --- 插入排序的JS实现

let A [5, 2, 4, 6, 1 ,3];// 插入排序 insertionSort (A) > {console.log("原数组>>>", A);for (let j1; j<A.length; j) {let key A[j];i j -1;while ( i > -1 && A[i] > key) {A[i1] A[i];i i-1;}A[i 1] key;}console.log(&q…

SAFESHE错误

今天写驱动编译的时候遇到一个问题&#xff0c;link一个比较老的lib时&#xff0c;报错&#xff1a; error LNK2026: module unsafe for SAFESEH image 解决办法&#xff1a; 在Source文件中加入一行 NO_SAFESEHTRUE 编译时候执行 build -cZg转载于:https://www.cnblogs.com/fa…

python之正则(一)

1.常用正则表达式: \d:数字[0-9] &#xff0c;实例:a\dc -> a1c\D:非数字[^\d],实例:a\Dc -> abc\s:空白字符[<空格>\t\r\n\f\v] 实例:a\sc ->a c\S:非空白字符[^\s] 实例:a\Sc ->abc\w:单词字符[A-Za-z0-9_] 实例:a\wc ->abc\W:非单词字符[^\W] *:匹配前…

逻辑读、物理读

逻辑读、物理读、预读的基本概念转载于:https://www.cnblogs.com/mySerilBlog/p/9208215.html

算法 --- 归并排序的js实现

let mergeSort (A, p, q, r) > {console.log("原数组>>>", A);let n1 q - p 1;let n2 r - q;let L new Array();let R new Array();for (let i 1; i < n1 1; i) {L[i -1] A[p i - 1];}for (let j 1; j < n2 1; j) {R[j-1] A[q j];}L[…

c#中的代理和事件

事件&#xff08;event&#xff09;是一个非常重要的概念&#xff0c;我们的程序时刻都在触发和接收着各种事件&#xff1a;鼠标点击事件&#xff0c;键盘事件&#xff0c;以及处理操作系统的各种事件。所谓事件就是由某个对象发出的消息。比如用户按下了某个按钮&#xff0c;某…

个人技术博客

一. Volley框架 在进行和服务器交互的时候需要发送请求&#xff0c;发现了volley这个好用易上手的框架。volley是一个异步网络通信框架&#xff0c;它的优点在于轻量级、适用于量小但传送频繁的请求操作 搭建请求的第一步就是新建一个请求队列RequestQueue queue Volley.newRe…

软件构造 第一章第二节 软件开发的质量属性

​软件构造 第一章第二节 软件开发的质量属性 1.软件系统质量指标 External quality factors affect users 外部质量因素影响用户 Internal quality factors affect the software itself and its developers 内部质量因素影响软件本身和它的开发者 External quality results fr…

css --- 让不同的浏览器加载不同的CSS

// 通过条件注释让不同的浏览器加载不同的CSS <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--> <!--[if IE]><!--> 所有的IE可识别 <![endif]--> <!--[if IE 6]> 仅IE6可识别 <![endif]--> <!--[if lt IE 6]> I…

정규식 문법 정리.초급

abcdefg a검색 abca abcbca abcabcdeda Cc 한개 캐릭터 [a] [ac] [a-c] [Cc] 수량자 1>* ( 0~무한대) 2> (1~무한대) 3.? () 4 {1,2} {Min,Max} [패턴]*{} 수량자.패턴…

css自媒体查询

准备工作1&#xff1a;设置Meta标签 首先我们在使用Media的时候需要先设置下面这段代码&#xff0c;来兼容移动设备的展示效果&#xff1a; <meta name"viewport" content"widthdevice-width, initial-scale1.0, maximum-scale1.0, user-scalableno">…

css --- 清除浮动

有时我们需要用到浮动,但又不想由于浮动的某些特性影响布局,这时就需要清除浮动 清除浮动主要应用的是CSS中的clear属性,clear属性定义了元素的哪一侧不允许出现浮动元素. 下面是两种应用比较广泛的清除浮动的方法: // 在需要的地方添加定义了clear:both的空标签 <style>…

数据可视化实现技术(canvas/svg/webGL)

数据可视化的实现技术和工具比较转载于:https://www.cnblogs.com/knuzy/p/9215632.html

Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)...

http://www.cnblogs.com/huangcong/archis.strip() .lstrip() .rstrip(,) 去空格及特殊符号复制字符串Python1 #strcpy(sStr1,sStr2)2 sStr1 strcpy3 sStr2 sStr14 sStr1 strcpy25 print sStr2连接字符串Python1 #strcat(sStr1,sStr2)2 sStr1 strcat3 sStr2 append4 sStr1…

java 将一个非空文件夹拷贝到另一个地方

没有处理异常&#xff0c;只是简单的抛出了。需要捕获的需修改一下。 public class Test001 { //把一个文件夹或文件移到另一个地方去。 public static void main(String[] args) throws Exception { File filenew File("D:\\testFolder"); new Test001().copyFileTo…

Python环境 及安装

windows 1、下载安装包 https://www.python.org/downloads/2、安装默认安装路径&#xff1a;C:\python273、配置环境变量【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行&#xff0c;双击】 -->…

MUI主界面菜单同时移动主体部分不出滚动条解决

mOffcanvas(侧滑导航-主界面、菜单同时移动) 生成代码 增加列表滚动OK 增加幻灯片就挂了 百度了半天 没发现问题 后来想起官网的一句话 除顶部导航、底部选项卡两个控件之外&#xff0c;其它控件都建议放在.mui-content控件内&#xff0c;在Hbuilder中输入mbody&#xff0c;可快…

范围查询 BETWEEN AND

查询&#xff1a;从表t_student里 查找 id 在1~10 之间的学生信息&#xff0c;并显示 id,name,age,email 信息 SELECT id,name,age,email FROM t_student WHERE id BETWEEN 1 AND 10转载于:https://www.cnblogs.com/hello-dummy/p/9216720.html