首页 > 代码库 > java

java

 

                                                                  Javascript

 

 

一.今天跟往常一样,还是先练习久久乘法表,但不同的是给乘法表加上了颜色。

            script里设置变量

        可是要怎么把变量名称放在document.Write()输出里产生作用呢,可是试了好几遍还是失败了。

 

function jiujiu(one){

                   for(var a = 1; a <= one; a++)

                   {

                            // var number=‘‘;//可以随意给数也可以不给。

                            var number = ‘‘;

                            if(a%2 == 0)

                            {

                                     number = ‘color1‘

                            }

                            else{

                                     number = ‘color2‘

                            }       

                            for(var b = 1; b <= a; b++)

                            {

                                     document.write("<div class=‘"+number+"‘>"+a+"x"+b+"="+a*b+"</div>")

                                     //把变量怎么换成字符串

                                     //确定要添加和替换的位置拆了用空格隔开看着清楚明了,因为在这里变量是一个单独的字符串,所以用双引号,例:class=‘"+number+"‘>

                            }

                                     document.write("<br>")

                  

                            document.write("<br>")

                }

}

                jiujiu(10)

 

 

 

 

二.把前一天没完成的下拉列表继续完成。

常用的事件有onclick(点击事件),onmouseover(划过事件),onmouseout(经过事件)

例:<body>

                <div  id="left" onm ouseout="mei()">

                   <div id="one" >贵州</div>

                   <div id="three">贵阳</div>

                </div>

                <div id="right" onm ouseout="mei()">

                   <div id="two" >黑龙江</div>

                   <div id="four">哈尔滨</div>

                </div>

                <div id="center">添加想要的东西</div>

                <script>

                   var a = document.getElementById(‘three‘)

                   var b = document.getElementById(‘four‘)

                   function showOne(){

                            a.style.display = ‘block‘

                            b.style.display = ‘none‘

                   }

                   function showTwo(){

                            a.style.display = ‘none‘

                            b.style.display = ‘block‘

                   }

                   function mei()

                   {

                            a.style.display = ‘none‘

                            b.style.display = ‘none‘   

                   }

                   mei()  //这个默认定位比较适合做导航条一类的。

</body>

样式在style里设置的threefourposition: absolute;

 

 

 

(这个加在bodyhtml的中间) <!-- 把想要的画面定住为<script>加上function后面的命名和值</script> 。例<script>c()</script> -->   (这个适合两侧的下拉列表)

 

Ponstion;大家都用直升机来形容它,它是不能乱用的,不然容易出错。

 

 

 

 

 

 

                                                                                                                2016122   周五

本文出自 “12244270” 博客,转载请与作者联系!

java