How to split a string at the first `/` (slash) and surround part of it in a `<span>`? How to split a string at the first `/` (slash) and surround part of it in a `<span>`? javascript javascript

How to split a string at the first `/` (slash) and surround part of it in a `<span>`?


Using split()

Snippet :

var data =$('#date').text();var arr = data.split('/');$("#date").html("<span>"+arr[0] + "</span></br>" + arr[1]+"/"+arr[2]);	  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><div id="date">23/05/2013</div>