View Full Version : Make trigger dissapear on click..

03-04-2009, 02:29 PM
In the code below what do I need to add such that when the reveal() function is triggered, the trigger dissapears.


<script type="text/javascript">
document.write('<style type="text/css">.detail {float:left;display:none;}#zero {display:block;}<\/style>');
function reveal(det){
if(!document.getElementById) return;
if (!document.getElementsByClassName){
document.getElementsByClassName = function(cn){
cn = cn.replace(/ +/g, ' ').split(' ');
var ar = [], testname = function(n){
for (var re, i = cn.length - 1; i > -1; --i){
re = new RegExp('(^|\W)' + cn[i] + '(\W|$)');
if(!re.test(n)) return false;
return true;
for(var d = document.all || document.getElementsByTagName('*'), i = 0; i < d.length; ++i)
ar[ar.length] = d[i];
return ar;
document.getElementsByClassName.spoof = true;
for (var d = document.getElementsByClassName('detail'), i = d.length - 1; i > -1; --i)
d[i].style.display = 'none';
document.getElementById(det).style.display = 'block';
if (document.getElementsByClassName.spoof)
document.getElementsByClassName.spoof = document.getElementsByClassName = null;

03-05-2009, 05:20 AM
It is unclear what's happening because we cannot see the associated markup. However, the code you have implies something like so:

<a href="#" onclick="reveal('some_id');return false;">Trigger</a>

If that's about right, or if you can do it like that, then the easiest way to make the trigger disappear would be:

<a href="#" onclick="this.style.visibility = 'hidden';reveal('some_id');return false;">Trigger</a>

or, depending upon whether or not you want it to just become invisible (above snippet) or to be removed from the layout as well:

<a href="#" onclick="this.style.display = 'none';reveal('some_id');return false;">Trigger</a>