Homer_J
Homer_J

Reputation: 3323

jQuery remove character from text

I have the following code:

$('#table1 .set2').each(function()
{
    alert($(this).html());
});

This brings back a range of %'s currently in an alert box.

99%
87%
12%

What I need to do is remove the % character so I am left with a number that I can use.

Any suggestions welcomed.

Upvotes: 0

Views: 8810

Answers (2)

Ammar Khan
Ammar Khan

Reputation: 2585

I believe, this should work for you

$('#table1 .set2').each(function()
    {
        var number=$(this).html().trim().slice(0,-1);
        alert(number);
    });

Upvotes: 0

j08691
j08691

Reputation: 208032

Change:

$(this).html()

to:

$(this).html().replace('%','')

jsFiddle example

Upvotes: 4

Related Questions