Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

269
Vistas
jQuery test for whether an object has a method?

Is it possible to test whether a jQuery object has a particular method? I've been looking, but so far without success. Thanks!

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

This should work:

if (!!$.prototype.functionName)
over 4 years ago · Santiago Trujillo Denunciar

0

Because jQuery methods are prototype into a jQuery object, you can test it from the prototype object.

if( $.isFunction( $.fn.someMethod ) ) {
    // it exists
}

This uses the jQuery.isFunction()[docs] method to see if $.fn.someMethod is indeed a function. (In jQuery jQuery.fn is a reference to the prototype object.)

over 4 years ago · Santiago Trujillo Denunciar

0

try

if ($.fn.method) {
    $('a').method(...);
}

or

if ($.method) {
    $.method(...);
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda