run button's click on page load
asp.net, javascript, jquery
Solution
<script>
$(document).ready(function () {
document.getElementById("osx").click();
});
</script>
or
<body onload="document.getElementById('osx').click();">
with id="osx" added to your input element
Problem
i have a input like this " ``` <input type='button' name='osx' value='Demo' class='osx demo' runat="server" /> ``` that when i click on this , it runs a jQuery plugin. now i want to call this input's click event on my page load, in fact i want to run it's plugin at page load, so i use this code : ``` <script> $("document").ready(function () { window.getElementById("osx").click(); }); </script> ``` but when i run my page , i get this error : Line: 16 Error: Object doesn't support property or method 'getElementById' can enyone help me ,please? i done all of your answers but non of them worked for me!!! here in my page's code : ``` <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <link type='text/css' href='css/osx.css' rel='stylesheet' media='screen' /> <script> $("document").ready(function () { document.getElementById("osx").click(); } </script> </head> <body> <div id='container'> <div id='content'> <div id='osx-modal'> <input id='osx' type='button' name='osx' value='Demo' class='osx demo' runat="server" /> or <a href='#' class='osx'>Demo</a> </div> <!-- modal content --> <div id="osx-modal-content"> <div id="osx-modal-title" dir="rtl"> OSX Style Modal Dialog</div> <div class="close"> <a href="#" class="simplemodal-close">x</a></div> <div id="osx-modal-data"> <h2> Hello! I'm SimpleModal!</h2> <p> SimpleModal is a lightweight jQuery Plugin which provides a powerful interface for modal dialog development. Think of it as a modal dialog framework.</p> <p> SimpleModal gives you the flexibility to build whatever you can envision, while shielding you from related cross-browser issues inherent with UI development..</p> <p> As you can see by this example, SimpleModal can be easily configured to behave like an OSX dialog. With a handful options, 2 custom callbacks and some styling, you have a visually appealing dialog that is ready to use!</p> <p> <button class="simplemodal-close"> Close</button> <span>(or press ESC or click the overlay)</span></p> </div> </div> </div> </div> <script type='text/javascript' src='js/jquery.simplemodal.js'></script> <script type='text/javascript' src='js/osx.js'></script> </body> </html> ``` where am i do wrong?