# JavaScript实现文本倒转

**URL:** <https://www.shiqidu.com/t/topic/340>\
**Category:** 开发调优\
**Tags:** JavaScript\
**Created:** [2017 年12 月 12 日 05:22 UTC](https://www.shiqidu.com/t/topic/340 "2017-12-12T05:22:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

作者： ![f32414](https://www.shiqidu.com/user_avatar/www.shiqidu.com/f32414/32/612_2.png) [@f32414](https://www.shiqidu.com/u/f32414)\
发布日期： [2017 年12 月 12 日 05:22 UTC](https://www.shiqidu.com/t/topic/340/1 "2017-12-12T05:22:41Z")

</div>

```html
<!DOCTYPE html>        
<html lang="en">        
<head>        
	<meta charset="UTF-8">        
	<title>Document</title>        
</head>        
<body>        
	        
</body>        
</html>        
<script>        
	var str = ('123456789');        
	var nstr = "";        
	var a;        
	for (var i = 0; i < str.length+1; i++) {        
		console.log(a = str.substring(str.length-i,str.length-i+1));        
			nstr +=a;        
	};        
	document.write(nstr);        
</script>  

```

---

<div class="post-metadata">

作者： ![f32414](https://www.shiqidu.com/user_avatar/www.shiqidu.com/f32414/32/612_2.png) [@f32414](https://www.shiqidu.com/u/f32414)\
发布日期： [2017 年12 月 12 日 05:26 UTC](https://www.shiqidu.com/t/topic/340/2 "2017-12-12T05:26:20Z")

</div>

第一次发东西，不太熟悉。。。求管理员大大拯救

---

<div class="post-metadata">

作者： ![Eureka](https://www.shiqidu.com/user_avatar/www.shiqidu.com/eureka/32/5_2.png) [@Eureka](https://www.shiqidu.com/u/Eureka)\
发布日期： [2017 年12 月 12 日 05:30 UTC](https://www.shiqidu.com/t/topic/340/3 "2017-12-12T05:30:19Z")

</div>

@f32414: 具体看这里 [https://www.shiqidu.com/p/164](https://www.shiqidu.com/p/164)

---

<div class="post-metadata">

作者： ![Eureka](https://www.shiqidu.com/user_avatar/www.shiqidu.com/eureka/32/5_2.png) [@Eureka](https://www.shiqidu.com/u/Eureka)\
发布日期： [2017 年12 月 12 日 05:30 UTC](https://www.shiqidu.com/t/topic/340/4 "2017-12-12T05:30:26Z")

</div>

![b4937bd193f86db7b48ff69b5f01f113.png](https://discourse.shiqidu.com/uploads_nj/article/20171212/b4937bd193f86db7b48ff69b5f01f113.png)
