我创建了一个JQuery脚本,该脚本通过html页面运行,我现在需要从该页面运行XML。
在脚本运行页面时,页面开头就是这样的。
<div id="main-container">
<div id="container" class="container " style="width: 1906px; height: 953px; margin: 0px auto; visibility: visible;">
<div class="inner" style="background-color: transparent; width: 1906px; height: 953px;">
<div class="second-container overflow-hidden" style="width: 1906px; height: 953px;">
<div class="layer" style="width: 1906px; height: 953px; visibility: hidden; display: block; left: 0px; right: auto; top: 0px; bottom: auto;">
<img class="bg" src="../img/bg.png" style="padding: 0px; border-width: 0px; width: 1906px; height: 953px; margin-left: -953px; margin-top: -476.5px; visibility: visible;">
其中类inner
和second-container
由jQuery自动创建,即在html本身中你将拥有...
<div id="main-container">
<div id="container" style="width: 1000px; height: 500px; margin: 0 auto;">
<div class="layer" style="delay: 1100; animation: all;">
<img class="bg" src="../img/bg.png" >
所以我所做的是以下内容:
XML:
<root
template.root.style="width: 1920px; height: 1080px; margin: 0 auto;">
<item
template.item.style="delay: 1100; animation: all;">
background="images/bg.png"
imageone="images/test.png"
imageoneclass="img1-b1"
template.image1.style="position: absolute; top: 10; left: 300px; direction: left; delay: 10;" />
</root>
JS:
<script type="text/javascript">
var player = jQuery;
player.noConflict();
player(document).ready(function () {
var body = documnet.getElementsByTagName("body");
player.ajax({
type="GET",
async: "false",
url: "data.xml",
dataType: "xml",
success: function (xml) {
var container = player('<div id="main-container"></div>).appendTo(body);
player(xml).find('root').each(function () {
var root = player('<div id="container"></div>.appendTo(container);
root.attr('style', player(this).attr('template.root.style'));
var layer = "player('<div id="layer"></div>.appendTo(root);
layer.attr('style', player(this).attr('template.item.style'));
});
我的问题是如何使用此原则将div
班layer
置于自动生成的div
inner
内?
再一次道歉,如果有任何错别字或丢失任何遗失的“或”,因为目前它正在运作,这只是一个案例,找出我所要求的是否可以做。