我座標我的屬性數據座標片串入兩個變量
<a class="cor" href="#" data-coordinates="37.650621, 55.740887"></a>
我需要切片他們分成兩個變量,這樣
<script>
//this must contain coordinate which is before ","
var firstCor = $('.cor').attr('data-coordinates');
//this must contain coordinate which is after ","
var lastCor = $('.cor').attr('data-coordinates');
</script>
那麼,我必須從兩個變量一個數據座標
留下第二值 – epascarello
@epascarello使用'.trim()' –
僅供參考,如果你需要一個空間用這個答案支持IE8,你需要使用polyfill來修剪 – epascarello