js截取扩展名
2016-11-28 本文已影响0人
教我情何以堪
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<style>
</style>
<script>
// 定义一个字符串
var str='aaa.doc.html.css';
/*var n=str.lastIndexOf('.'); //位置
alert(str.substring(n+1));*/
var arr=str.split('.');
alert(arr[arr.length-1]);
</script>
</head>
<body>
</body>
</html>