12

Here is my code It's working perfect in all browsers but not in Firefox.

I tried many thing but didn't work at all. Please can some one help me on this issue. Am I doing something wrong.?

Is there any other way.?

I'M USING .innerText because values are coming from

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

There is no error on 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>
user3474130
  • 135
  • 1
  • 1
  • 7

1 Answers1

29

innerText is the "old Internet Explorer" way of doing it.

Try textContent instead. Ideally you should use elem.textContent || elem.innerText, but if you're using jQuery you can just do jQuery("#the_id_here").text().

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • tried but not working – user3474130 Apr 10 '14 at 15:16
  • @user3474130 Please provide feedback that helps us solve your problem. To be clear, do you mean that `var PostStartone = document.getElementById('jr-rating-wrapper-jr_stars-new-0').innerText || document.getElementById('jr-rating-wrapper-jr_stars-new-0').textContent;` is not working, or that `$('#jr-rating-wrapper-jr_stars-new-0').text()` is not working? This answer supplies two suggestions; it would be helpful if you could explain exactly *how* each solution is failing, – apsillers Apr 10 '14 at 15:17
  • @user3474130 Have you tried `var PostStartone = document.getElementById('jr-rating-wrapper-jr_stars-new-0').innerText || document.getElementById('jr-rating-wrapper-jr_stars-new-0').textContent` as suggested in this answer? Did it not work? – apsillers Apr 10 '14 at 15:20
  • There is problem with those 3 variable any thing else is working good if define variable manually. – user3474130 Apr 10 '14 at 15:21
  • 6
    It's like talking to a brick wall... ***TRY `textContent`!*** – Niet the Dark Absol Apr 10 '14 at 15:23
  • -1, sorry, but nope. `innerText` is more [profoundly different](http://perfectionkills.com/the-poor-misunderstood-innerText/) from `textContent`, and actually is tremendously more useful. `innerText` gives an "approximation" of how the text is _actually presented_ in the browser, as opposed to `textContent`, which returns just about the _tag-stripped markup source_, adding very little value, or even extra problems (like the loss of word boundaries). – Sz. Nov 20 '17 at 18:09
  • @Sz. Interesting link, however I personally stand by `textContent` as the "more correct" option here, specifically because it preserves the source. That being said I've only ever really used these on tiny things like `--` or the like so y'know my opinion may not count for much XD – Niet the Dark Absol Nov 20 '17 at 20:13
  • Niet, another interesting fact I learned since then: now Firefox has finally joined the others, and also implemented `innerText` as well (in 45+). (It's actually not a matter of correctness, they are different features. Sometimes you may need the source, as you noted, and there are cases where you'd need the ("rendered") text roughly as the user can actually see it. And it's a nice, fat can of worms either way. :) ) – Sz. Nov 23 '17 at 22:16