[JS/jQuery] Using argument (this) passed via element eventhandler
- by Kel
Hey guys,
I want to use the argument I pass (this) in a JS function and treat it as an jQuery variable.
Example:
<script>    
function useMe(obj){
  $(obj).val();
  ...
  ... 
  ...
}
</script>
<select id="selectid" onChange="useMe(this)">
    <option>......</option>
</select>
Is there a possibility to treat the passed argument as a jQuery element?
Btw. I need to do it this way, because the select-element isn't created on load. The select element will be created later asynchronously. 
So, this won't work:
$("select").each(function (i){
    var select_id = $(this).attr("id");                
    $(this).change(function(e){  
because it doesn't exist yet.
Thanks for your help.