Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

remove text using query

Posted on 2013-11-02
4
420 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Head to not include on scroll 4 23
jquery + C#.net radiobuttonlist 3 30
What if i make webbased alternative for MS Access 5 67
Running a javascript project in WebStorm 2 25
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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)

856 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