Html 如何使用两个不同的链接显示和隐藏div
我有一个HTML页面,我将有作为“显示”的链接,同时点击,我需要显示div区域。DIV有iframe的地方 通常,在加载HTML页面时,div应该处于隐藏状态,而单击时只应显示它 我需要关闭按钮内的链接..而我需要关闭潜水是隐藏点击Html 如何使用两个不同的链接显示和隐藏div,html,Html,我有一个HTML页面,我将有作为“显示”的链接,同时点击,我需要显示div区域。DIV有iframe的地方 通常,在加载HTML页面时,div应该处于隐藏状态,而单击时只应显示它 我需要关闭按钮内的链接..而我需要关闭潜水是隐藏点击 <a href="#" onClick="toggleDisplay('toHide')">a</a> function toggleDisplay(id) { if (!document.getElementById)
<a href="#" onClick="toggleDisplay('toHide')">a</a>
function toggleDisplay(id)
{
if (!document.getElementById) { return; }
var el = document.getElementById('straddle');
if (el.style.display == ''){
el.style.display = 'none';
}else {
el.style.display = '';
}
}
功能切换显示(id)
{
如果(!document.getElementById){return;}
var el=document.getElementById('straddle');
如果(el.style.display==''){
el.style.display='none';
}否则{
el.style.display='';
}
}
我不想要这个切换功能
请帮帮我。你的javascript
<script type="text/javascript">
<!--
var whatever = document.getElementById('mydiv');
whatever.style.display = 'none';
function show(){
whatever.style.display = 'block';
}
function hide(){
whatever.style.display = 'none';
}
//-->
</script>
然后是HTML
<a href="#" onclick="show();">Click here to show element </a>
<br/>
<div id="mydiv">
This will disappear and reappear and
<a href="#" onclick="hide();">Click here remove element</a></div>`
这将消失并重新出现
`
您的javascript
<script type="text/javascript">
<!--
var whatever = document.getElementById('mydiv');
whatever.style.display = 'none';
function show(){
whatever.style.display = 'block';
}
function hide(){
whatever.style.display = 'none';
}
//-->
</script>
然后是HTML
<a href="#" onclick="show();">Click here to show element </a>
<br/>
<div id="mydiv">
This will disappear and reappear and
<a href="#" onclick="hide();">Click here remove element</a></div>`
这将消失并重新出现
`
使用jQuery:
$(document).ready(function() {
$('#link1').click(function() { $('#div').css({ display:'none' }) })
$('#link2').click(function() { $('#div').css({ display:'block' }) })
})
使用jQuery:
$(document).ready(function() {
$('#link1').click(function() { $('#div').css({ display:'none' }) })
$('#link2').click(function() { $('#div').css({ display:'block' }) })
})
您可能需要(Iframe
可能需要一段时间才能加载,所以让它加载)
HTML:
<a href="#" id="show">Show</a>
<div id="straddle">
<div id="close">Close</div>
<iframe width='100%' src="http://heera.it"></iframe>
</div>
更新:添加了相关的css
#跨越{显示:无;}
#接近{
浮动:对;
光标:指针;
显示:内联块;
}
您可能需要(Iframe
可能需要一段时间才能加载,所以让它加载)
HTML:
<a href="#" id="show">Show</a>
<div id="straddle">
<div id="close">Close</div>
<iframe width='100%' src="http://heera.it"></iframe>
</div>
更新:添加了相关的css
#跨越{显示:无;}
#接近{
浮动:对;
光标:指针;
显示:内联块;
}
如果(!document.getElementById)
似乎不正确1)如果(!document.getElementById)您要找哪个ID?2) 显示什么:“”??如果我知道的没错,如果希望div可见,可以将其设置为display:block/inline/inline block。3) 你想在div里面有一个关闭按钮,但我需要两个不同的链接来显示和隐藏。。如果(!document.getElementById)似乎不正确,则在HTML页面中显示按钮在DIV中隐藏按钮1)如果(!document.getElementById)您要查找哪个ID?2) 显示什么:“”??如果我知道的没错,如果希望div可见,可以将其设置为display:block/inline/inline block。3) 你想在div里面有一个关闭按钮,但我需要两个不同的链接来显示和隐藏。。显示按钮在HTML页面隐藏按钮里面,但我需要两个不同的链接显示和隐藏。。在HTML页面中显示按钮在内部隐藏按钮DIV@user3007361刚刚为你编辑了它,现在应该工作,因为你想它,但我需要两个不同的链接显示和隐藏。。在HTML页面中显示按钮在内部隐藏按钮DIV@user3007361刚刚为您编辑了它,现在应该可以按您想要的方式工作了。第一次打开HTML页面时..DIV应该隐藏..onlu=y单击show我需要显示Div@user3007361,是的,第一次是隐藏的,检查,添加css
。谢谢..在我的HTML页面中,我将显示一些数据..单击我的div后,应在该数据上方..在打开HTML页面时第一次插入该HTMLHi..div应隐藏..仅在单击show时u=y我需要显示Div@user3007361,是的,第一次是隐藏的,检查,添加css
。谢谢..在我的HTML页面中,我将显示一些数据..单击我的div后,应该位于该数据上方..在该HTML内部