[英]startPanel with onclick joomla
我試圖顯示和隱藏在的Joomla一個div但不工作
這是我要隱藏的div
<div id="muestra" style="display:none;">
<? php JToolBarHelper::editListX(); ?>
</div>
我正在調用javascript函數
echo $pane->startPanel('<span onclick="mostrar(muestra);">Proveedores</span>','id_panel') ;
我的JavaScript是
function mostrar(id){
if (document.getElementById){
var el = document.getElementById(id);
alert(el);
el.style.display = (el.style.display == 'none') ? 'block' : 'none';
}
}
window.onload = function(){
mostrar('muestra');
}
</script>
第一次是el = Object,但是第二次是null,並且從不接受值。
有任何想法嗎?
試試這個
HTML:
<div id="muestra" style="display:none;">
<?php JToolBarHelper::editListX(); ?>
</div>
PHP:
echo $pane->startPanel('<span onclick="mostrar();">Proveedores</span>','id_panel') ;
Javascript:
<script type="text/javascript">
function mostrar(){
if (document.getElementById('muestra').style.display == 'none') {
document.getElementById('muestra').style.display = 'block';
}
else {
document.getElementById('muestra').style.display = 'none';
}
}
</script>
嘗試用撇號將muestra包圍起來 :
echo $pane->startPanel('<span onclick="mostrar(\'muestra\');">Proveedores</span>','id_panel');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.