2014-04-10 19 views
11

Ecco il mio codice Funziona perfettamente in tutti i browser ma non in Firefox.Perché .nernerText non funziona in Firefox?

Ho provato molte cose ma non ha funzionato affatto. Per favore qualcuno può aiutarmi su questo problema. Sto facendo qualcosa di sbagliato?

C'è qualche altro modo?

sto usando .innerText perché i valori sono provenienti da

<span class="jr-rating-wrapper-jr_stars-new-0"> 
4.5 
</span> 

non ci sono errori su console.

<script type="text/javascript"> 
    jQuery('#submitButton').click(function(){ 
    var PostStartone = document.getElementById('jr-rating-wrapper-jr_stars-new-0').innerText; 
    var PostStarSec = document.getElementById('jr-rating-wrapper-jr_stars-new-1').innerText; 
    var PostStarThird = document.getElementById('jr-rating-wrapper-jr_stars-new-2').innerText; 
    var PostCapVal = document.getElementById('code').value; 
    var PostRBVal = ""; 
    var selected = jQuery("div.jr_fieldDiv input[type='radio']:checked"); 
    PostRBVal = selected.val(); 
    jQuery.post("http://xyz/x/Update.php", { 
     GetStarOneValue : PostStartone , 
     GetStarSecValue : PostStarSec , 
     GetStarThirdValue : PostStarThird , 
     GetCaptchValue : PostCapVal, 
     GetRadioBTNValue : PostRBVal}); 
}); 
</script> 
+0

che errore stai ottenendo? – pj013

+0

Hai riscontrato errori nella console? – Andy

+0

Inoltre, quale bit di quel codice non funziona. Hai inserito dei breakpoint per vedere il punto in cui si trova prima di rompere? – Andy

risposta

26

innerText è il modo "vecchio Internet Explorer" di farlo.

Prova textContent invece. Idealmente dovresti usare elem.textContent || elem.innerText, ma se usi jQuery puoi semplicemente fare jQuery("#the_id_here").text().

+0

provato ma non funzionante – user3474130

+0

@ user3474130 Si prega di fornire un feedback che ci aiuta a risolvere il tuo problema. Per essere chiari, intendi che 'var PostStartone = document.getElementById ('jr-rating-wrapper-jr_stars-new-0'). InnerText || document.getElementById ('jr-rating-wrapper-jr_stars-new-0'). textContent; 'non funziona, o che' $ ('# jr-rating-wrapper-jr_stars-new-0'). text() 'non funziona? Questa risposta fornisce due suggerimenti; sarebbe utile se potessi spiegare esattamente * come * ogni soluzione fallisce, – apsillers

+0

@ user3474130 Hai provato 'var PostStartone = document.getElementById ('jr-rating-wrapper-jr_stars-new-0'). innerText || document.getElementById ('jr-rating-wrapper-jr_stars-new-0'). textContent' come suggerito in questa risposta? Non ha funzionato? – apsillers

Problemi correlati