简体   繁体   English

使用onclick joomla的startPanel

[英]startPanel with onclick joomla

I'm trying to show and hide a div in Joomla but doesn't work 我试图显示和隐藏在的Joomla一个div但不工作

This is the div I'm trying to hide 这是我要隐藏的div

<div id="muestra" style="display:none;">
   <? php JToolBarHelper::editListX(); ?>
</div>

The I'm calling the javascript function 我正在调用javascript函数

echo $pane->startPanel('<span onclick="mostrar(muestra);">Proveedores</span>','id_panel') ;

My javascript is 我的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>

the first time el=Object, but the second one is null and never takes a value. 第一次是el = Object,但是第二次是null,并且从不接受值。

any ideas? 有任何想法吗?

Give this a try 试试这个

HTML: HTML:

<div id="muestra" style="display:none;">
   <?php JToolBarHelper::editListX(); ?>
</div>

PHP: PHP:

echo $pane->startPanel('<span onclick="mostrar();">Proveedores</span>','id_panel') ;

Javascript: 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM