Mozilla Firefox得不到值innerText [英] Mozilla Firefox not getting value innerText

查看:116
本文介绍了Mozilla Firefox得不到值innerText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的JavaScript代码:

This is my JavaScript code:

function selectRow(objTR) {
    for (i = 0; i < ddlModalityList.options.length; i++) {
        if (ddlModalityList.options[i].text == objTR.cells[1].innerText.trim()) break;
    }

    ddlModalityList.options[i].selected = true;
    txtSSAETitle.value = objTR.cells[2].innerText.trim();
    txtSSName.value = objTR.cells[3].innerText.trim();
}

这是转发器代码。在行上点击我传递tr的id,并在相应的下拉列表和文本框中显示相应的td值。此代码在IE中正常工作,但在Mozilla Firefox中失败。

This is repeater code. On row click I am passing id of tr and displaying respective td value in respective dropdownlist and textboxes. This code works fine in IE but fails in Mozilla Firefox.

<tr onclick="selectRow(this);">   
    <td class="csstablelisttd" style="display: none;" >
        <%#Eval("Acq_Modality_ID")%>
    </td>                     
    <td class="csstablelisttd" >                            
        <asp:Label ID="lblModality" runat="server" Text='<%#Eval("Modality")%>'></asp:Label>
    </td>

    <td class="csstablelisttd">
        <asp:Label ID="lblSchdledStAETitle" runat="server" Text='<%#Eval("Scheduled_Station_AE_Title")%>'></asp:Label>
    </td>
    <td class="csstablelisttd">
        <asp:Label ID="lblSchdleStationAEName" runat="server" Text='<%#Eval("SCHEDULED_STATION_NAME")%>'></asp:Label>
    </td>
</tr>


推荐答案

Firefox不支持 innerText 。您可以使用 textContent 。但是,旧的IE不支持 textContent ,因此您需要使用一个并回退到另一个。

Firefox does not support innerText. You can use textContent instead. However, older IE does not support textContent, so you'll need to use one and fall back to the other.

function getInnerText(el) {
    return el.textContent || el.innerText;
}

注意,它们不一样,但出于您的目的,它会很好。

Note that they're not identical, but for your purposes it will be fine.

这篇关于Mozilla Firefox得不到值innerText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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