inline data in script

by Akram kamal

HTML

<h1>
        jQuery And Script Tags
    </h1>
 
    <div id="scripts">
 
        <script type="text/plain">
            Plain text in script tag.
        </script>
 
        <script type="text/plain">
            More plain text in script tag.
        </script>
 
    </div>
 
    <ul id="output" />

JavaScript

//http://www.bennadel.com/blog/1603-jquery-and-script-tags-as-data-containers.htm
// When DOM loads, initialize.
        $(
            function(){
                // Gather script block in our target DIV.
                var jScripts = $( "#scripts script" );

                // Get a reference to our output list.
                var jOutput = $( "#output" );

                // Loop over each script to copy the data from
                // the tag to the output list.
                jScripts.each(
                    function( intI, objScript ){
                        var jThis = $( this );

                        // Append html of script tag to list.
                        jOutput.append(
                            "<li>" +
                            jThis.html() +
                            "</li>"
                            );
                    }
                    );

            }
            );