<script type=text/javascript>
$(document).ready(function() {
var tem = $("h1").text();
var i = 0;
while (tem[i++]);
var j = 0;
i = i - 1;
var tem1 = new Array();
while (i >= 0) {
tem1[j]=tem[i];
i--;
j++;
}
alert(tem1.join(''));
});
</script>
2、js面试题中的字符串反转
复制代码 代码示例:
//字符串反转
var j = '1234567';
var result = '';
for(var i=j.length; i >=0; i--) {
result += j.substring(i, i-1);
}
console.log(result);