Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
quiere usar funciones dentro del método jQuery listo

Tengo una pregunta similar antes , mi pregunta era sobre cómo acceder a todas las funciones de JavaScript en la consola del navegador web incluso si estaban dentro de window.onload = function() {// code and functions} , pero esta vez quiero hacer lo mismo con jQuery :

 $(document).ready(function() { // I want to access all the functions that are here in the web console })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar la misma sintaxis que en su pregunta anterior. Simplemente asigne la función a la window .

El siguiente ejemplo ilustra lo que quiero decir. Tenga en cuenta que no necesita setTimeout() , esto es solo para este ejemplo aquí para ejecutar automáticamente your_function() cuando se define.

 $(document).ready(function() { window.your_function = function(){ console.log("your function"); }; your_function(); }); // setTimeout() is needed because the $.ready() function was not executed when // this code block is reached, the function(){your_function();} is needed because // the your_function() is not defined when the code is reached setTimeout(function(){ your_function(); }, 500);
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Nota 2: Sugiero no definir funciones globales en $(document).ready() si no hay una buena razón para ello. Puede definir las funciones fuera y luego llamarlas en $(document).ready() .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!