Filter by Tags

How to split the string in jquery or javascript

Votes

0

0 0
<div id="date">21/02/2010</div>




I want to format this date, first I want to break string at like the 2nd character and have the rest in the next line. And if it possible with jQuery to append two tags. as follows:



21
02/
2010



 
Kushal Kumar
Posted on : Thu, Dec 28, 2017
Views : 151
Comments

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Answers (1)


0

Using Split()

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>

 

 

 

Kushal Kumar
Thu, Feb 01, 2018
Loading...
Comments

Edit Answer

Submit
This answer will permanently deleted. Do you really want to delete this Answer ?
To Add your Answer Please
LogIn | SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp