.innerText为什么在Firefox中不起作用? [英] Why is .innerText not working in Firefox?

查看:96
本文介绍了.innerText为什么在Firefox中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的代码
它在所有浏览器中都很完美,但不是在Firefox中。 我尝试了很多事情,但没有根本不工作。
请有人可以帮我解决这个问题。
我做错了什么?



有没有其他方法?

我使用.innerText,因为值来自 p>

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

在控制台上没有错误。

 < 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>


解决方案

innerText $ b 尝试使用 textContent 来代替。理想情况下,您应该使用 elem.textContent || elem.innerText ,但是如果你使用jQuery,你可以做 jQuery(#the_id_here)。text()


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>

解决方案

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().

这篇关于.innerText为什么在Firefox中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆