2014-02-05 32 views

回答

3

雖然做同樣與核心JavaScript更容易但如果你想在jQuery的只有那麼試試這個

$("td").filter(function(){ 
      var $txt = $(this).text(); 
      var $m = $txt.match(/^(\d+)-(\d+)-(\d+)$/); 
      var $new = $m[3] + "-" + $m[2] + "-" + $m[1]; 
      return $(this).text($new); 
      //or 
      //return $(this).text($(this).text().replace(/^(\d+)-(\d+)-(\d+)$/, "$3-$2-$1")); 
    }); 

working DEMO

+0

hmmmm $ m對我來說是空的 – KJW

相關問題