Javascript中有自己的各种type以及伪类pseudo,在Jquery的库中应该有着更多的应用。
1.在任何时候变量都会被认为一个boolean值
var x = ""
if ( x )
console.log("x defaulted to true")
else
console.log("x defaulted to false")
结果就是
x defaulted to false
原因就是空即为false,满则true。
2.String中单引号和双引号定义的字符串一样吗?
答案是一样的而且,单引号中可以包含双引号,双引号也可以包含单引号,如果在单引号中特别使用双引号用\指出。
"You make 'me' sad."
'Holy "cranking" moses!'
"<a href=\"home\">Home</a>"
a) 内建函数
"hello".charAt(0) // "h"
"hello".toUpperCase() // "HELLO"
"Hello".toLowerCase() // "hello"
"hello".replace(/e|o/g, "x") // "hxllx"
"1,2,3".split(",") // ["1", "2", "3"]
b)其他应用
//Length Property
//All strings have a length property.
"Hello".length // 5
"".length // 0
//Boolean Default
//An empty string defaults to false:
!"" // true
!"hello" // false
3.Number
JS中的数字double-precision 64-bit format IEEE 754 values。
//Boolean Default
//If a number is zero, it defaults to false:
!0 // true
!1 // false
!-1 // false
//特别需要注意js的精度,它可是按double精度来的
//values, the following result is not an error:
0.1 + 0.2 // 0.30000000000000004
//math应用
Math.PI // 3.141592653589793
Math.cos(Math.PI) // -1
//从字符串到数字
parseInt("123") = 123 (implicit decimal)
parseInt("010") = 8 (implicit octal)
parseInt("0xCAFE") = 51966 (implicit hexadecimal)
parseInt("010", 10) = 10 (explicit decimal)
parseInt("11", 2) = 3 (explicit binary)(二进制)
parseFloat("10.10") = 10.1
//数字到字符串,可没有toString哦,加一个字符串就可以
"" + 1 + 2; // "12"
"" + (1 + 2); // "3"
//or
String(1) + String(2); //"12"
String(1 + 2); //"3"
// 特别NaN and Infinity
parseInt("hello", 10) // NaN
isNaN(parseInt("hello", 10)) // true
//Division by zero results in Infinity无限大:
1 / 0 // Infinity
//Both NaN and Infinity are of type "number":
typeof NaN // "number"
typeof Infinity // "number"
//小心Note that NaN compares in a strange way:
NaN == NaN // false (!) //错的
isNaN(value) //对的
Infinity == Infinity // true
分享到:
相关推荐
jQuery 就不多说了,这是JS的一个函数库,比较常用,我们今天是就jQuery的三种用于css的操作进行总结 $(selector).css(“name”,”value”) $(selector).css({properties}) $(selector).css(name) $(selector).css...
css3特性中最令人兴奋的莫过于选择器的增强,例如属性选择器可以根据某个属性值来选择标记,位置选择器可以根据子元素的位置来选择标记。 在目前很多使用的很多浏览器,例如IE7,主要支持css2.大部分属性选择器都不...
jQuery是时下比较流行的一个js库,能够用简单的代码做出理想的效果,就像官网上说的那样“write less ,do more”。Jquery在一定程度上改写了以往对JavaScript的写法,本人就用jquery实现上篇中用ajax实现异步通信的...
代码如下:<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <... <head>...script src=”js/jquery-1.3.2.js
代码如下: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <... <head>...script src=”js/jquery-1.3.2.j
代码如下: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <... <head>...script src=”js/jquery-1.3.2.j
JS学习笔记相关文档 Login.html学习 placeholder 属性规定可描述输入字段预期值的简短的提示信息(比如:一个样本值或者预期格式的短描述)。 该提示会在用户输入值之前显示在输入字段中。 注意:placeholder 属性...
什么是DOM对象?...!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” ...1-4</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /
事件绑定函数 事件的绑定函数为如下形式: .bind(type [,data],fn) type:类型 如click….. data:参数 fn:事件执行的函数 例子 代码如下: $(function(){ $(#id1).click(function(){ $(#id2).show();//id2显示 }) ; })...
1. 使用jquery 到jquery.com下载jquery.js当前版本是1.4.2 新建一个html页面 代码如下: <!DOCTYPE html><BR><html lang=”en”><BR><head> <meta http-equiv=”Content-Type” content=”text/...
DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta ...
DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta ...
DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta ...
jquery 笔记: 代码如下: $(“input[name=’radio_name’]:checked”).val() <input type=”radio” value=”1″ name=”radio_name” />1 <input type=”radio” value=”2″ name=”radio_name” />2 ...
有兴趣刚需的可以自己下载,非常实用的jquery代码,可以完美运行,有能力的还可以二次修改!
下个月就要过年了,感觉有点瞎忙。翻了翻博客,感觉这个月都在打酱油啊。借口那么多,其实真的有点懒了,呵呵! 我争取在放假前,将...input type=tel maxlength=6 class=ipt-real-nick/> <div class=ipts-
jqGrid 是一个用来显示网格数据的jQuery插件,通过使用jqGrid可以轻松实现前端页面与后台数据的ajax异步通信。 一、要引用的文件 要使用jqGrid,首先页面上要引入如下css与js文件。 1、css <link href=/css/ui...
首先需要的文件有jquery.js,jquery.autocomplete.js,jquery.autocomplete.js,这三个文件,哪里有?百度、谷歌都可以找到。...SCRIPT language=javascript src=”../../js/jquery.autocomplete.js” type=text/javasc
2012-05-27 11:07 3,045,963 '工程师应该掌握的20个模拟电路.',doc_type,pdf.pdf 2012-05-27 11:03 5,876,128 Android中文API.pdf 2012-05-27 11:03 1,349,809 Business Objects入门教程(1).pdf 2012-05-27 11:03 1,...
今天弄了一下午终于自制成功,主要使用jQuery和CSS,实现功能基本和京东一样。 功能介绍: 1、鼠标停留导航; 2、根据子列表的高度,自动调整对齐方式(顶端对齐/父类目对齐); 3、父子类目样式一致。 功能...