gpt4 book ai didi

javascript - JQuery 在 1.7.1 版本中未设置 'textcontent'

转载 作者:行者123 更新时间:2023-11-28 21:11:36 24 4
gpt4 key购买 nike

我有以下代码,它为 HTML 中的元素设置目标、href 和文本内容,这在 JQuery 1.4.1 和 1.5.1 中工作得很好,但更新到 1.7.1 后,它不会更改 '可见元素的 textcontent' 属性,href 已更新。

 $("#uriEmma").attr('textcontent', emmaUri);
$("#uriEmma").attr('href', emmaUri);
$("#uriEmma").attr('target', '_blank');

有什么想法吗?

最佳答案

您应该使用.prop()和正确的大小写:textContentExample

来自文档:

The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior. As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.

关于javascript - JQuery 在 1.7.1 版本中未设置 'textcontent',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8488283/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com