Solved

remove text using query

Posted on 2013-11-02
4
417 Views
Last Modified: 2013-11-02
Dear experts,

I am using fivestar module to rate different kind of content from my website. The problem is that I don´t know how to remove  the parenthesis that surrounds a text as the following:

<span class="total-votes">(<span>4</span>votes)</span>

Is there a way to leave only the number and  remove the parenthesis and the word votes? something like this:

<span class="total-votes">4</span>

Thanks in advance,

Winter
0
Comment
Question by:glepiza
  • 2
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 300 total points
ID: 39619031
Try
$('span.total-votes').text(function(_, text) {
    return text.replace(/\(|votes\)/g, '');
});

Open in new window


http://jsbin.com/OTaBEbo/1/edit?html,js,output
0
 

Author Comment

by:glepiza
ID: 39619050
<span class="total-votes">(<span>1</span>vote)</span>

would that be:

      $('span.total-votes').text(function(_, text) {
          return text.replace(/\(|votes\)/g, '');
          return text.replace(/\(|vote\)/g, '');
      
      });
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39619058
$('span.total-votes').text(function(_, text) {
    return text.replace(/\(|votes?\)/g, '');
});

Open in new window

0
 

Author Comment

by:glepiza
ID: 39619275
Thank you very much expert.

Winter
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now