childNodes not working in Firefox and Chrome but working in IE

前端 未结 8 1953
太阳男子
太阳男子 2021-01-06 07:41

I have a gridview in its 3rd cell, there is textbox control, I am calling javascript function on onchange.

Can some body tell me why this is not working in Firefox a

8条回答
  •  情话喂你
    2021-01-06 08:00

    If you are looking for the text, use grd.rows[rowindex].cells[3].childNodes[0].data for non-IE browsers.

    Getting text value of an Element Node

    var oCell = grd.rows[rowindex].cells[3];
    alert(oCell.textContent || oCell.innerText)
    

    Getting text value of a Text Node (less safe compared to previous)

    var oText = grd.rows[rowindex].cells[3].childNodes[0];
    alert(oCell.data || oCell.value)
    

提交回复
热议问题