本文目录一览:
一段js代码求解
哥哥你也把代码给缩进一下啊,看着好累的
Mgly.diff = function (lhs, rhs, options){
var opts = jQuery.extend({
ignorews : false
}, options);
this.codeify = new Mgly.CodeifyText({
lhs : lhs,
rhs : rhs,
options : opts
});
var lhs_ctx = {codes : this.codeify.getCodes('lhs'),modified : {}};
var rhs_ctx = {codes : this.codeify.getCodes('rhs'),modified : {}};
var max = (lhs_ctx.codes.length + rhs_ctx.codes.length + 1);
var vector_d = Array(2 * max + 2);
var vector_u = Array(2 * max + 2);
this._lcs(lhs_ctx, 0, lhs_ctx.codes.length, rhs_ctx, 0, rhs_ctx.codes.length, vector_u, vector_d);
this._optimize(lhs_ctx);
this._optimize(rhs_ctx);
this.items = this._create_diffs(lhs_ctx, rhs_ctx);//items中存放创建的差异信息
};
还有你的代码没有复制齐全。很多方法没有复制过来
js的一段代码解读
JS也有面向对象的。
上面定义的function其实在定义一个对象
下面使用的newemp=new employee("zhangming",'A002');
其实在创建一个对象,并且将对象的属性赋值
然后输出的时候,当然是对象的属性值了
JS创建对象,你还需要多了解一些的。并不像JAVA那样明显
了解多了,看起来就明显了
求一段JS代码
按钮驱动文字闪烁
脚本说明:
第一步:把如下代码加入body区域中
SCRIPT LANGUAGE="JavaScript"
var x=9;
var strobe="on"
if (navigator.appName == "Netscape") {
visShow="'show'";
visHide="'hide'";
docStyle="document.";
styleDoc="";
}
else {
visHide="'hidden'";
visShow="'visible'";
docStyle="";
styleDoc=".style";
}
/SCRIPT
SCRIPT LANGUAGE="JavaScript"
function hide1() {
eval(docStyle 'object1' styleDoc '.visibility=' visHide);
}
function hide2() {
eval(docStyle 'object2' styleDoc '.visibility=' visHide);
}
function hide3() {
eval(docStyle 'object3' styleDoc '.visibility=' visHide);
}
function hide4() {
eval(docStyle 'object4' styleDoc '.visibility=' visHide);
}
function hide5() {
eval(docStyle 'object5' styleDoc '.visibility=' visHide);
}
function hide6() {
eval(docStyle 'object6' styleDoc '.visibility=' visHide);
}
function hide7() {
eval(docStyle 'object7' styleDoc '.visibility=' visHide);
}
function hide8() {
eval(docStyle 'object8' styleDoc '.visibility=' visHide);
}
function hide9() {
eval(docStyle 'object9' styleDoc '.visibility=' visHide);
}
function hide10() {
eval(docStyle 'object10' styleDoc '.visibility=' visHide);
}
function show1() {
eval(docStyle 'object1' styleDoc '.visibility=' visShow);
hide2(),hide3();
}
function show2() {
eval(docStyle 'object2' styleDoc '.visibility=' visShow);
hide1(),hide3();
}
function show3() {
eval(docStyle 'object3' styleDoc '.visibility=' visShow);
hide2(),hide4();
}
function show4() {
eval(docStyle 'object4' styleDoc '.visibility=' visShow);
hide3(),hide5();
}
function show5() {
eval(docStyle 'object5' styleDoc '.visibility=' visShow);
hide4(),hide6();
}
function show6() {
eval(docStyle 'object6' styleDoc '.visibility=' visShow);
hide5(),hide7();
}
function show7() {
eval(docStyle 'object7' styleDoc '.visibility=' visShow);
hide6(),hide8();
}
function show8() {
eval(docStyle 'object8' styleDoc '.visibility=' visShow);
hide7(),hide9();
}
function show9() {
eval(docStyle 'object9' styleDoc '.visibility=' visShow);
hide8(),hide10();
}
function show10() {
eval(docStyle 'object10' styleDoc '.visibility=' visShow);
hide9();
}
function strobe1() {
x =1;
eval("show" x "()");
if (x10) setTimeout("strobe1()", 75);
else if (strobe=="on") strobe2();
}
function strobe2() {
x-=1;
eval("show" x "()");
if (x1) setTimeout("strobe2()", 75);
else strobe1();
}
function strobeOn() {
x=9;
strobe="on";
strobe1();
}
function strobeOff() {
strobe="off";
}
/SCRIPT
div id="vis" style="position:absolute; visibility:show; left:175px; top:280px; z-index:1"
table cellpadding=2 border=1tr
tdcenterbStrobe:/b/center/font/a/td
tda href="javascript:strobeOn()"
font color="#000000"centeron/center/font/a/td
tda href="javascript:strobeOff()"
font color="#000000"centeroff/center/font/a/td
/tr/table/div
div id="object1" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=#eaffff width=175 height=50tdcenterbfont color="#F9F9F9"JavaScript Planet/font/b/center/td/table
/div
div id="object2" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#ECECEC"JavaScript Planet/font/b/center/td/table
/div
div id="object3" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#D5D5D5"JavaScript Planet/font/b/center/td/table
/div
div id="object4" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#C0C0C0"JavaScript Planet/font/b/center/td/table
/div
div id="object5" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#b0b0b0"JavaScript Planet/font/b/center/td/table
/div
div id="object6" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#939393"JavaScript Planet/font/b/center/td/table
/div
div id="object7" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#808080"JavaScript Planet/font/b/center/td/table
/div
div id="object8" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#6b6b6b"JavaScript Planet/font/b/center/td/table
/div
div id="object9" style="position:absolute; visibility:hide; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#424242"JavaScript Planet/font/b/center/td/table
/div
div id="object10" style="position:absolute; visibility:show; left:175px; top:300px; z-index:1"
table border=1 bgcolor=eaffff width=175 height=50tdcenterbfont color="#000000"JavaScript Planet/font/b/center/td/table
/divP
/FONT/CENTER
Js编程语言中,自调用函数是什么?举个Js代码例子解释一下!
自调用函数:
顾名思义,有2个意思
《1》自行调用的函数:
就是指,函数在页面载入后或者之前就自行调用,无需借助其他函数或方法来启动;
例如:
(function(win){
win.alert(11);
})(window);
《2》自己调用自己的函数:
就是指,递归:在一个函数里面调用自己的函数,当符合一定规则时,跳出自我调用,就是递归。
例如:
var fn = function(n){
if(n == 1) return 1;
else return n * fn(n-1);
}
求一段JS代码!鼠标离开文本框后提交数据!
form name="from1"
input type="text" name="txt1" id="txt1" onblur="getVal(this.id)" /
input type="text" name="txt2" id="txt2" onblur="getVal(this.id)" /
/form
script type="text/javascript"
function getVal(id)
{
alert(document.getElementById(id).value);
}
/script
注:onblur事件是在失去焦点的时候,不知道符不符合你的要求
你还可以试试onmouseout,鼠标一移出文本框就触发