<script language="javascript">
String.prototype.trim = function()
{
// 用正则表达式将前后空格
// 用空字符串替代。
return this.replace(/(^\s*)|(\s*$)/g, "");
}
var t5 = new Number(document.all.sTime2.value);
var t6 = new Number(document.all.eTime2.value);
alert(t5)//值为6
alert(t6)//值为6
if (t5.trim()==t6.trim()){//这样试试。。...
}
</script>
String.prototype.trim = function()
{
// 用正则表达式将前后空格
// 用空字符串替代。
return this.replace(/(^\s*)|(\s*$)/g, "");
}
var t5 = new Number(document.all.sTime2.value);
var t6 = new Number(document.all.eTime2.value);
alert(t5)//值为6
alert(t6)//值为6
if (t5.trim()==t6.trim()){//这样试试。。...
}
</script>
解决方案 »
- 如何获取浏览器所在区域?
- js打开新窗口
- 表格显示与隐藏的问题,请帮帮忙,谢谢
- 关于解决ie6 fixed问题
- 哪位大侠,能帮忙完善这段代码?或达到相同功能也行。----------目的是在C#代码中获以脚本返回值。
- 非常急:关于js文件返回繁体信息的问题
- 为什么我这个数组总是出错呢?
- 我想在New HTML Page1.htm来改变<iframe>的高度
- iframe 跨域子页面操作父页面的问题,真心求教
- JavaScript中关于call函数的理解
- 怎么判断checkbox有几个被选中
- 抱..歉..只..剩..10..分..了... 请问在Html的字符串连接上单引号和双引号有啥区别. 都搞了好几天了, 还是没明白.
{alert("t5 == t6")}
else{
alert("t5 != t6")
}var t5 = new Number(document.all.sTime2.value);
is object
var t6 = new Number(document.all.sTime2.value);
is object
t5!=t6
alert("t5==t6");
}
返回指定对象的原始值。object.valueOf( )必选项 object 参数是任意固有 JScript 对象。 说明
每个 JScript 固有对象的 valueOf 方法定义不同。对象 返回值
Array 数组的元素被转换为字符串,这些字符串由逗号分隔,连接在一起。其操作与 Array.toString 和 Array.join 方法相同。
Boolean Boolean 值。
Date 存储的时间是从 1970 年 1 月 1 日午夜开始计的毫秒数 UTC。
Function 函数本身。
Number 数字值。
Object 对象本身。这是默认情况。
String 字符串值。
Math 和 Error 对象没有 valueOf 方法。
<input value="1" name=eTime2>
<script language=javascript>
var t5 = new Number(document.all.sTime2.value);
var t6 = new Number(document.all.eTime2.value);
alert(t5)//值为6
alert(t6)//值为6
if (Number.valueOf(t5)==Number.valueOf(t6)){//却不执行函数体内部语句 这是为什么啊
alert("呵呵")
}
</script>
而你的数字型的,所以没有这个函数