Suppost your string is some thing this "1,2,3,4," and you want to remove last comming comma from this string . Below is the javascript code -
<script type="text/javascript">
var comId = '1,2,3,4,' ;
check = comId.slice(-1);
if(check == ',') {
comId = comId .slice(0, -1);
alert(comId);
}
</script>
Output : Below is the output of the above javascript code in screne shot -
Don't forget to leave a comment.
Chears
Happy Coding :)
<script type="text/javascript">
var comId = '1,2,3,4,' ;
check = comId.slice(-1);
if(check == ',') {
comId = comId .slice(0, -1);
alert(comId);
}
</script>
Output : Below is the output of the above javascript code in screne shot -
Don't forget to leave a comment.
Chears
Happy Coding :)