当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - jQuery parents() having different outputs in Firefox and Chrome

问题描述:

This question already has an answer here:

  • 'innerText' works in IE, but not in Firefox

    15 answers

网友答案:

JavaScript is handled differently in browsers. It could be to do with with that. As you are already using jQuery, you could just carry on using it for your second query. Also if you are in control of your HTML, you can make your first query a lot simpler by adding a class to the second parant table:

var allTitles = $("[href='...']").closest(".your-class").find(".field_text");
var name = allTitles.children().first().text();
console.log(name);
网友答案:

The problem was actually with children.innerText, it doesn't work with Firefox.

Just changed to children.textContent and it solved the problem.

Reference: children.innerText is not working in firefox

分享给朋友:
您可能感兴趣的文章:
随机阅读: