1

I want to sub string and remove the , which appears within the span tag and display the name alone. Below are the two cases which needs to work.

Case1: <span class="datatableheader">No results found, </span>
Case2: <span class="datatableheader">Jude Gomes, </span>

A single function should help in removing the , in both cases and display the result as

<span class="datatableheader">No results found </span>
<span class="datatableheader">Jude Gomes </span>

Appreciate for any help.

Thanks

1
  • Couldn't have said it better myself @Kolink. Very irritating when people do not show their appreciation for the effort others put in! Especially those who manage to find the time to answer as many questions as they can Commented Mar 22, 2012 at 12:54

3 Answers 3

2
$(".datatableheader").html ($(".datatableheader").html().replace(",",""));
Sign up to request clarification or add additional context in comments.

Comments

1

It's not widely recognized that .html accepts a callback function:

$('.datatableheader').html(function(i,old) {
    return old.replace(/, ?/g, '');
});​

http://jsfiddle.net/3fBY4/1/

1 Comment

+1, if the selector '.datatableheader' evaluates to more than one element this comes handy.
0

you can try this also

 var parts = id.split(':'); //because u have case1: or case2: 
// it will split into string in array//

$('#parts[1]').replace(",",""));
//try to print that it will work

nice question.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.