2012-07-06 75 views
0

我不確定爲什麼item count括號不會在這個小小的小提琴示例中被刪除。jquery兩個替換函數

編輯:這是我看到工作答案的結果。

$.fn.itemcount = function(){ 
 
    var text = $(this).text(); 
 
    text = text.replace("(","").replace(")",""); 
 
    $(this).text(text); 
 
}; 
 

 
$("#prc").itemcount(); 
 

 

 
$.fn.sidecartcost = function(){ 
 
    var el = $(this); 
 
    var text = $(this).text(); 
 
    text = text.replace("Your sub total is", "").replace(". ", ""); 
 
    $(this).text(text); 
 
}; 
 

 

 

 
$('.SideCartCost').sidecartcost();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 

 
<div id="prc">(7 Items)</div> 
 
<div class="blank">Woo</div> 
 
<div class="SideCartCost">Your sub total is $300.03. </div>

回答