?
Solved

remove text using query

Posted on 2013-11-02
4
Medium Priority
?
438 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 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 1200 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 53

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

Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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)
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…
Suggested Courses

719 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