Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type='text/javascript'>
        var html="<ul><li>item1</li><li>item2</li><li>item3</li></ul>";
        var code = "alert('here');";
    </script>
    <script type='text/javascript'>
        $(document).ready(function(){
            $("#test1").click(function(){
                // get the current html
                var cur = $("#dest").html();
                $("#dest").html(cur + "<br />" + html);
        
                // add the script
                var oScript = document.createElement( "script" );
                oScript.language = "javascript";
                oScript.type = "text/javascript";
                oScript.defer = true;
                oScript.text = code;
                $("#dest")[0].appendChild( oScript );                
            });
        });
    </script>
</head>
<body>
    <div id='dest'>This is normal content.</div>
    <button id='test1'>test</button>
</body>
    
</html>
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers