TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Man Down
NA
48
3.4k
How to add comma to separate numbers - JavaScript
Feb 6 2018 3:55 AM
I am trying to print an number in JavaScript with commas as separators. but when i add comma it will give me Nan value For example, I want to show the number 170607 as "170,607". How would I go about doing this?
HTML :
<
div
class
=
"row about-stats stats block-1-4 block-m-1-2 block-mob-full"
data-aos
=
"fade-up"
>
<
div
class
=
"col-block stats__col "
>
<
div
class
=
"stats__count"
>
4
</
div
>
</
div
>
<
div
class
=
"col-block stats__col"
>
<
div
class
=
"stats__count"
>
40
</
div
>
</
div
>
<
div
class
=
"col-block stats__col"
>
<
div
class
=
"stats__count"
>
170607
</
div
>
</
div
>
<
div
class
=
"col-block stats__col"
>
<
div
class
=
"stats__count"
>
3447
</
div
>
</
div
>
</
div
>
Script:
/* Stat Counter
* ------------------------------------------------------ */
var clStatCount = function() {
var statSection = $(
".about-stats"
),
stats = $(
".stats__count"
);
statSection.waypoint({
handler: function(direction) {
if
(direction ===
"down"
) {
stats.each(function () {
var $
this
= $(
this
);
$({ Counter: 0 }).animate({ Counter: $
this
.text() }, {
duration: 4000,
easing:
'swing'
,
step: function (curValue) {
$
this
.text(Math.ceil(curValue));
}
});
});
}
// trigger once only
this
.destroy();
},
offset:
"90%"
});
};
Reply
Answers (
8
)
Call function on click of column in hyperlink itself
Get second Column value,When user clicks on First column Val