Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Attach event test page</title>
        <script type="text/javascript">
        window.onload = (function() {
            if(typeof jQuery == 'undefined'){
                var script = document.createElement("script");
                script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";
                script.type = "text/javascript";
                script.onload = script.onreadystatechange = function(){
                    injectImg();
                };
                document.body.appendChild( script );
            }else{
                injectImg();
            }
        });
        function injectImg(){
           $('#sas-window-header').append("<img src='sandwich.jpg' id='gif' alt='Sandwich' />");
           $('#gif').click(function(){
               alert('Clicked');
           });
                   }
        </script>
    </head>
    <body>
        <p>The header</p>
        <div id="sas-window-header"></div>
    </body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers