2017-08-29 27 views
0

我在波斯網站內使用TimeCircles.js插件。爲了將波斯語數字改爲英文,我已經有了一個替換每個數字的函數。
在這種情況下,我會得到內部編號爲「span」的文本,並將其存儲在變量中。轉換成波斯語後,我console.log的數量,它被正確轉換。但顯然「span」中的文字不能被覆蓋。如何更改TimeCircles.js中的數字?

這裏是我的js獲取和設置

translate(); 
function translate() { 
    var day = $('.textDiv_Days span').text(), 
     hour = $('.textDiv_Hours span').text(), 
     min = $('.textDiv_Minutes span').text(), 
     sec = $('.textDiv_Seconds span').text(); 


    day = pd(day); //pd() returns persian number 
    hour = pd(hour); 
    min = pd(min); 
    sec = pd(sec); 

    console.log(day,hour,min,sec); //Converting is successful 

    $('.textDiv_Days span').text(day); // not working !!!! 
    $('.textDiv_Hours span').text(hour); // not working !!!! 
    $('.textDiv_Minutes span').text(min); // not working !!!! 
    $('.textDiv_Seconds span').text(sec); // not working !!!! 


    setTimeout(translate,500); 
} 

我是不正確的設置數量或覆蓋數根據插件結構這種方式是不可能的數量。 你的建議是什麼?

預先感謝您。

回答

0

我認爲你的jQuery選擇器沒有選擇元素是很有可能的。 嘗試:

$('span.textDiv_Days').text(day); 
+0

要更具體的選擇器可以是「div.textDiv_Days跨度」。你所提供的是選擇一個不存在的班級名稱。 – Negar