thank you for your advice.. It looks better now :)
I am new in jQuery :) I still learning it. and Its just a demo..
and I have still have a same problem.. the socond div's position is
still going down when I append a new div. (insideParent2)
This two div (insideParent and insideParent2) have to be child of
parentElem..
code is like that now..
<script type="text/javascript">
function addEvent(){
jQuery("#insideParent").append('<div id="my1Div"><a href="#"
style="border:0"><img src="images/demo_img/penguin2.jpg"
style="border: 0"/></a>');
}
function removeElement() {
jQuery("#my1Div").remove();
}
</script>
<div id="parentElem">
<div id="insideParent"></div>
<div id="insideParent2"><img src="images/demo_img/penguin.jpg"
border="0"/></div>
</div>
<a href="#" onclick="addEvent();"><b>Add Element</b></a>
<a href="javascript:;" onclick="removeElement();"><b>Remove Element</
b></a>
<script type="text/javascript">
jQuery(document).ready(
function(ev, ui)
{
jQuery('#insideParent').draggable({
zIndex: 1000,
ghosting: false,
opacity: 0.7,
containment : 'parent'
});
jQuery('#insideParent2').draggable(
{
zIndex: 1000,
ghosting: false,
opacity: 0.7,
containment : 'parent'
}
);
}
);
</script>
No comments:
Post a Comment