JQuery media plugin not working on creating the tag dynamically
<p>I am new to jquery and javascript programming. I am trying to create a div and put a video using jquery. On browsing the internet I came to know about jquery media plugin to play the videos.</p>

<p>I am showing a thumbnail of the video and on clicking it I am dynamically appending new vid and trying to call jquery media plugin code. Code for jquery media plugin can be found at <a href="http://jquery.malsup.com/media/#options" rel="nofollow">http://jquery.malsup.com/media/#options</a>.</p>

<p>My sample code is as follows:</p>

<pre><code> img_container.click(function (event) {
                    var innerImage = $(this).find('img');
                    var imgId = innerImage.attr('id');

                    var vidPath = '..\\content\\video\\' + imgId;
                    var containerOffsetHeight = _self.image_wrapper_height / 2;

                    var containerWidth = $(this).width();
                    var containerHeight = $(this).height();

                    var $vidContainer = $('&lt;div/&gt;', { 'class': 'videoContainer', 'id': 'vidContainer', 'width': containerWidth, 'height': containerHeight });
                    $vidContainer.css('position', 'absolute');

                    $vidContainer.css('top', '0px');

                    $vidContainer.css('left', '0px');
                    if (containerWidth &lt; _self.image_wrapper_width) {
                        var dif = _self.image_wrapper_width - containerWidth;
                        $vidContainer.css('left', (dif / 2) + 'px');
                    };


                    var $media = $('&lt;a href="' + vidPath + '" class="media"&gt;Watch my movie!&lt;/a&gt;');

                    $vidContainer.append($media);

                    //$('.media').media();
                    $('.media').media({ width: 400, height: 300, autoplay: true }); 

                    $vidContainer.prependTo('.ad-image-wrapper');
                    $('.ad-image').hide();

                });
</code></pre>

<p>So my question is : as said in jquery media plugin documentation why the anchor tag not getting converted to div tag even on calling the media() function. I have tried to debug the code but I am not able to follow the code flow because of code jumping between jquery code and the media code.</p>

<p>I am wondering is it because of creating the node dynamically and then calling the method? Any suggestions are most welcome.</p>

<p>Thanks</p>
