object parameters in jquery functions
hi everyone, somebody could tell me how can i pass a variable that store a selection in jquery to a function in jquery, for instance:
var valor=$("#selector").val();// global variable with a selection
function main(){//this function calls the function generar
var resultado = generar(valor);//generar needs a parameter(a jquery object or selector ), here i pass valor, my global variable with my selection
}
function generar(obj){///function with need an object to make selections such as get attributes and other things
obj.attr('rel');
}
well my doubt is how can i do it because in function generar obj doesn't show me the options of attr and other methods , i think is because is wrong the way i declare the parameter, or if this is not posible, i don´t know if i need to specify a type for the parameter such function generar(jQuery obj), but this doesn`t work.
thank you