<p id="demo">Click the button to display the array values after the split.</p>
<button onclick="myFunction()">Try it</button>
function myFunction()
{
var str = "http://maps.gstatic.com/mapfiles/place_api/icons/generic_business-71.png";
var res = str.substring(49).split("-71",1); //generic_business
document.getElementById("demo").innerHTML=res;
}
google maps icon
https://github.com/bmorgan21/stash/blob/master/lib/icons.coffeejavascript只取數字 用正規表示
var str=$(".area_product").css('left');//出來會是312px
var reg=/[^\d]+/img;
str=str.replace(reg,"");
alert(str);//出來會是312
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。