2016-02-12 27 views
1

我想更改頁面上的兩個價格而不是一個。所以改變,如果65英鎊或35英鎊。用jquery文本替換2個值替換

如何添加一個/或這個功能?

$('#shipping-method > table > tbody > tr:nth-child(2) > td.price > label') 

.filter(function() { 

return $.trim(this.innerHTML) == "£65.00"; 

}).text('Quote Price'); 
+0

使用[邏輯運算符(嘗試https://developer.mozilla.org/en-US/文檔/網絡/的JavaScript /參考/運營/ Logical_Operators)?我不確定我是否理解這個問題。 – Stryner

+0

'return this.innerHTML.match(/£(65 | 35).00 /);'是一個解決方案。 –

+0

我想要==「£65.00或£35.00」; – flint781

回答

0

使用RegExp.prototype.test()

$("#shipping-method > table > tbody > tr:nth-child(2) > td.price > label") 
.filter(function() { 
    return /£65\.00|£35\.00/.test(this.innerHTML); 
}).text("Quote Price"); 
0

您可以使用簡單或||操作

$('#shipping-method > table > tbody > tr:nth-child(2) > td.price > label') 

.filter(function() { 

return ($.trim(this.innerHTML) == "£65.00" || $.trim(this.innerHTML) == "£35.00"); 

}).text('Quote Price');