Home > Web Front-end > JS Tutorial > body text

js冒泡法和数组转换成字符串示例代码_javascript技巧

WBOY
Release: 2016-05-16 17:25:42
Original
1377 people have browsed it

js代码:

复制代码 代码如下:

window.onload = function(){
var mian = document.getElementById( "mian" );
var mian1 = document.getElementById( "mian1" );
var str = mian.innerHTML;
var arry = [];
var len = str.length;
for( var i = 0; i arry[ i ] = str[ i ];
};
function paix1( arry ){
var temp;
while( len > 0 ){
for( var j = 0; j if( arry[ j ] > arry[ j+1 ] ){
temp = arry[ j ];
arry[ j ] = arry[ j + 1 ];
arry[ j + 1 ] = temp;
};
};
len--;
};
return arry;
};
mian1.innerHTML = paix1(arry).join(""); // 把数组转换成为字符串
};

html代码:
复制代码 代码如下:

vdwsxdfrthspas


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!