Je voudrais écrire une fonction jquery qui accepte soit un élément dom ou son identifiant comme entrée:jquery: tester si la variable d'entrée est un élément dom
function myfunction(myinput){
// pseudocode:
// if (myinput is dom element){
// var myID = $(myinput).attr('id');
// } else {
// var myID = myinput;
// }
// Do stuff with myID ...
}
Question: Comment puis-je savoir si myInput est un dom élément???
Cela a déjà été posée: http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you- check-if-a-javascript-object-is-a-dom-object –