gpt4 book ai didi

javascript - 在javascript中正确使用它吗?

转载 作者:行者123 更新时间:2023-11-30 07:02:33 26 4
gpt4 key购买 nike

<分区>

我曾经打过这个电话:

var link = $('<a />', { 'class': 'prop' + index, title: elt, text: elt });
link.on('click', switchLabel);

使用 switchLabel 如下:

function switchLabel(e) {
$('#' + this.className.replace('prop','corr')).text(this.title);
}

我刚刚意识到 this 很难理解它在 javascript 中指的是什么,所以我替换为:

function switchLabel(e) {
var source = e.currentTarget;
$('#' + source.className.replace('prop','corr')).text(source.title);
}

我说的对吗?请为您的答案添加一些解释,我们(js noobs)可以学习。

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