gpt4 book ai didi

javascript - jQuery 从另一个函数收集函数内的数据

转载 作者:行者123 更新时间:2023-11-28 12:14:25 26 4
gpt4 key购买 nike

是否可以在函数运行时从另一个函数收集数据?

//常用函数

function collectingData(){
var name = 'tom';
return name
}

//我的目标在这里

$('.myDiv').click(function(){

// here I want data from another function
// collectingData()

if( name == 'tom' ){
//here I have to finish based of data
}

})

最佳答案

您已经从collectingData()返回名称;所以,定义一个变量,做你想做的事情,

 $('.myDiv').click(function(){
// here I want data from another function
// collectingData()
var name = collectingData();
if( name == 'tom' ){
//here I have to finish based of data
}

})

关于javascript - jQuery 从另一个函数收集函数内的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52565465/

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