How to run a JavaScript function on html body load (onload) with jQuery

1 Answer

0 votes
<!DOCTYPE html>
<html>
  
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
  
<body>

<p id="p-id"></p>

<script>

// jQuery

 
function f() 
{
    document.write("function");
}

$(document).ready(f);

/*
run:
  
function
    
*/

</script>

</body>
</html>

 



answered Jul 29, 2015 by avibootz
...