Jquery如何从此函数返回var? [英] Jquery how do I return the var from this function?

查看:67
本文介绍了Jquery如何从此函数返回var?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直未定义,请帮忙!这只是我第二天使用Jquery LOL!

I keep getting "undefined", please help! this is just my second day using Jquery LOL!

var id;

$('.nav-link').click(function() {
  id = $(this).attr('id');
  $container.cycle(id.replace('#', ''));
  
  return false;
});

alert(id);





我的尝试:



我尝试过使用return id语句,但没有运气。



What I have tried:

I have tried using the return id statement, but no luck.

var id;

$('.nav-link').click(function() {
  id = $(this).attr('id');
  $container.cycle(id.replace('#', ''));

  return false;
});

return id;
alert(id);

推荐答案

' < span class =code-string>。nav-link')。click( function (){
id =
('.nav-link').click(function() { id =


this )。attr(' id');
(this).attr('id');


container.cycle(id.replace(' #'' '));

返回 false ;
});

alert(id);
container.cycle(id.replace('#', '')); return false; }); alert(id);





我的尝试:



我尝试过使用return id语句,但没有运气。



What I have tried:

I have tried using the return id statement, but no luck.

var id;


这篇关于Jquery如何从此函数返回var?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆