Dynamically Creating Html Divs With Js From Xml
Im looking for a bit of Yoda like guidance on a project im working on. Im trying to dynamically generate div's in a web page based around XML data which is read in from a php serve
Solution 1:
Try using jQuery. It simplifies the task that you are trying to do.
http://api.jquery.com/category/manipulation/
Eg.
var newDiv = $('<div/>').text(sampleText);
parentDiv.append(newDiv);
Useful example of using jquery to do your task:
Solution 2:
i have this code in a jquery popup here is the code
jQuery(document).ready(function(){
    var showmask = function() {
        var dialogLeft = ((jQuery(window).width() - jQuery("#outerFbDialog").outerWidth()) / 2) + jQuery(window).scrollLeft() + "px";
        var dialogTop = "100px";
        /* uncomment this to place dialog in the center of window.
        var dialogTop = ((jQuery(window).height() - jQuery("#outerFbDialog").outerHeight()) / 2) +  jQuery(window).scrollTop()  +"px";
        */jQuery("#themask").css({'width':jQuery(window).width(),'height':jQuery(document).height()});
        jQuery("#themask").fadeTo('slow',0.7);
        jQuery("#outerFbDialog").css({'left': dialogLeft,'top':dialogTop});
        jQuery("#outerFbDialog").show();
        $('#themask').click(function () {
            jQuery(this).hide();
            jQuery("#outerFbDialog").hide();
        });             
    }
    // check for escape key 
    $(document).click(function(e) { 
        jQuery("#themask").hide();
        jQuery("#outerFbDialog").hide();        
    });
    showmask();
});
Post a Comment for "Dynamically Creating Html Divs With Js From Xml"