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.pswp.cn/news/251522.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/251522.shtml
英文地址,請注明出處:http://en.pswp.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