I would like to write a jquery function that accepts either a dom element or its id as input:
function myfunction(myinput){ // pseudocode: // if (myinput i
You would implement your function like this:
function myfunction(myinput){ if (myinput.nodeType){ var myID = $(myinput).attr('id'); } else { var myID = myinput; } // Do stuff with myID ...
}
More information about nodeType.