What is the best way to pass the var full to function b. I don\'t want to use global variables. Is return the only option.
You can pass a variable to a function by defining it as follows:
function b(x) {
alert(x);
}
and then calling it by stating its name and passing a variable as the argument:
b(full);
So in the context of your code:
$("body").click(function(e){
var name = $(e.target)[0].nodeName;
var nameid = $(e.target)[0].id;
var classname = $(name+"#"+nameid).attr('class');
var full = name+"#"+nameid;
console.log(nameid);
function b(x){
alert(x);
};
b(full);
});