Solved

remove text using query

Posted on 2013-11-02
4
421 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
[X]
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
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript Loan Calculator Error 3 35
JavaScript code not working 3 33
ModalPopup  question 22 38
HTML editor custom button 3 59
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…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

733 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