I am trying to set up a 404 page so that it will show a random graphic each time a user hits it. Currently the way I have it coded, the graphic is only loaded some of the time(I'd say it's about 50/50 right now). Just looking for a better way to code it so that one of the divs will be shown every time.
Here is my HTML:
<div id="errorpages">
    <div class="error">
        <img src="404.gif">
    </div>
    <div class="error">
        <img src="4042.gif">
    </div>
</div>
And the JavaScript:
<script type="text/javascript">
this.random404 = function(){
    var length = $("#errorpages div").length;
    var ran = Math.floor(Math.random()*length) + 1;
    $("#errorpages div:nth-child(" + ran + ")").show();
};
$(document).ready(function(){
    $('.error').hide();
    random404();
});
</script>
Any help would be greatly appreciated, thanks!
 
     
     
    