以下是我用于 div 内容的拖放功能的代码..
<style type="text/css">
.gap
{
border:1px solid black
}
</style>
<script type="text/javascript">
function toggle_visibility(id,nana) {
var e =document.getElementById(id);
var label = document.getElementById(nana);
if(e.style.display == 'none')
{
label.innerHTML = label.innerHTML.replace("[+]","[-]");
e.style.display = 'block';
//col.innerHTML=valu;
}
else
{
label.innerHTML = label.innerHTML.replace("[-]","[+]");
e.style.display = 'none';
}
}
function edit(id,item)
{
var e = document.getElementById(id);
var f = document.getElementById(item);
document.getElementById('id4').innerHTML=e.innerHTML;
e.innerHTML=f.innerHTML;
window.location=window.location;
}
function cancel(id,item)
{
document.getElementById(id).innerHTML=document.getElementById(item).innerHTML;
}
function submit(id,item)
{
document.getElementById(id).innerHTML=document.getElementById(item).innerHTML;
}
</script>
<div class="gap" ><a href="#" onclick="toggle_visibility('id1','x');" id="x">Click here<div style="float:right;">[+]</div></a></div>
<div id="id1" style="display:none;">This is foo</div>
<a href="#" onclick="toggle_visibility('id2','y');" id="y"><div id="click1" style="float:left;">Click here1</div>[+]</a>
<div id="id2" style="display:none;">click here1
<div> <a href="#" onclick="edit('id2','id3');">Edit</a></div>
<div> <a href="submit.php" onclick="submit('id2','id3');">submit</a></div>
</div>
<div id="id3" style="display:none;">Edit
<div> <a href="#" onclick="cancel('id2','id4')">cancel</a></div>
</div>
<div id="id4" style="display:none;"></div>
现在,当我单击任何 div 时,它会展开,但问题是浏览器正在从顶部刷新。因为我需要再次向下并应该看到内容..
当我单击任何特定的 div 时,我想将其保留在特定的 div 上。
请帮助我..谢谢