岁月总是愈来愈短 日子也总是愈来愈快 珍惜
JavaScript
JavaScript把数字转换为字符
六 3rd
具体方法
1,This conversion-through-concatenation feature of JavaScript results in an idiom that you may occasionally see: to convert a number to a string, simply add the empty string to it:
var n_as_string = n + "";
2,To make number-to-string conversions more explicit, use the String( ) function:
var string_value = String(number);
3,Another technique for converting numbers to 更多 >
JavaScript字符串中的转义序列值
六 3rd
表面上看没什么作用 但是如果一个单引号里面出现这种情况就只有这么办了!
'You\'re right, it can\'t be a quote'
那么JavaScript的转义序列到底有哪些了
JavaScript 转义序列 序列 代表的字符 \0 NULL 字符(\u0000). \b 退格符 (\u0008). \t 水平制表符 (\u0009). \n 换行符(\u000A). \v 垂直制表符 (\u000B). \f 换页符(\u000C). \r 回车符(\u000D). \" 双引号 (\u0022). \' 单引号或撇号(\u0027). \\ 反斜线符号(\u005C). \xXX The Latin-1 character specified by the two hexadecimal digits XX. \uXXXX The Unicode character specified by the four hexadecimal 更多 >使用XMLHttpRequest详解
六 2nd
使用 XMLHttpRequest 仅仅3个步骤而已:
- 1,Creating an XMLHttpRequest object
- 2,Specifying and submitting your HTTP request to a web server //指定http并向一个web server提交
- 3,Synchronously or asynchronously retrieving the server’s response //同步或异步获取服务器响应
1,创建一个XMLHttpRequest object
大部分浏览器可以用
var request = new XMLHttpRequest();
Prior to Internet Explorer 7, IE does not have a native XMLHttpRequest() constructor function. In IE 5 and 6
var request = 更多 >
关于JavaScript大小写敏感
六 1st
JavaScript是一种区分大小写的语言。
这就是说,在输入语言的关键字,变量名,函数名以及所有的标示符时,都必须采取一致的字符大小写形式。如,关键字“while”就必须输入“while”,而不能是“While”,“WHILE”等等。
但是在HTML里面是不区分大小写的(XHTML是区分的)。由于他和客户端JavaScript紧密相连,所以容易混淆。例如,在HTML中的onclick属性有时候也可以为onClick,但是在JavaScript或XHTML里面就只能是onclick。
指定div来createElement
五 28th
function addDiv(){
for(i=1;i< =5;i++){
listdiv = document.getElementById('songslist');
var newElement = document.createElement('div');
var newText = document.createTextNode(i+" "+"haha");
document.body.appendChild(newElement);
newElement.id = i;
if(i%2 == 0)
{
newElement.className = 'newDivClass';
}else{
newElement.className = 'newDivClass2';
}
newElement.setAttribute('name ','newDivName');
newElement.style.lineHeight = '25px';
newElement.style.textIndent = '24';
newElement.style.width = '490px';
newElement.style.height = '24px';
newElement.style.margin = '0 auto';
newElement.appendChild(newText);
var newA = document.createElement("a");
newA.href = "#";
newA.title = "从播放列表里删除该歌曲!";
newA.innerHTML = "删除"+i;
newA.index_no = i;
newElement.appendChild(newA);
listdiv.appendChild(newElement);
}
}
更多 > prototype.js常用函数和用法
五 28th