Remove Last Character from String jQuery

Remove Last Character from String jQuery

Today, We want to share with you Remove Last Character from String jQuery.
In this post we will show you javascript remove last comma in string, hear for javascript remove character from string at index we will give you demo and example for implement.
In this post, we will learn about remove first and last comma from string in javascript with an example.

Remove Last Character from String jQuery

There are the Following The simple About Remove Last Character from String jQuery Full Information With Example and source code.

As I will cover this Post with live Working example to develop Remove Last Character from String jQuery, so the some major files and Directory structures for this example is following below.simple jQuery is a very fast light weight, small, as well as more lots of the feature-rich JavaScript more uniq library

  • index.html
  Check all checkboxes in Angular js

Remove last comma from string jquery

index.html

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.html.

var uniqVal = "JaydeepGondaliya";
var results = uniqVal.substr(0, uniqVal.length - 4);

// Result is now "JaydeepGonda"

var uniqVal = "JaydeepGondaliya";
var results = uniqVal.substr(2);

// Result is now "ydeepGondaliya"

Remove Last Character from String jQuery

index.html

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>remove last comma from string jquery</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $('.myliveBtnEx').click(function (event) {
                var uniqVal = $.trim($('.mycricketer').val());
                var suChar = uniqVal.slice(-1);
                if (suChar == ',' || suChar == '.') {
                    uniqVal = uniqVal.slice(0, -1);
                }
                $("#data-preview").text(uniqVal);
            });
        });
    </script>

</head>
<body>
    <div>
        <h2>Simple Remove last comma from string using jquery</h2>
        <table>
            <tr>
                <td>
                    <input type="text" class="mycricketer" value="virat, dhoni, Yuvarj, Rohit sharma, Dhavan," />
                </td>
                <td>
                    <button class="myliveBtnEx">Remove</button>
                </td>
            </tr>
            <tr>
                <td>
                    <div id="data-preview" style="color:blue;"></div>
                </td>
            </tr>
        </table>
    </div>
</body>
</html>

Remove Last Character from String jQuery – Output

Remove Last Character from String jQuery - Remove Last Character from String jQuery
Remove Last Character from String jQuery
Angular 6 CRUD Operations Application Tutorials

Read :

  Laravel Check if Object is empty Examples

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Remove Last Character from String jQuery.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

avatar
  Subscribe  
Notify of