0

I have a function that shows and hides a table when a element is clicked. But when the table content of the table is shown, the page goes up, so I would like to have an anchor to the element of the table. How can I do it?

function hideShowTable(id, fila){
    var mostrado=0;
    var primerBlock=0;
    var elem2 = 0;
    var elem = document.getElementById(id);
    if(elem.style.display=='block'){
        mostrado=1;
        elem.style.display='none';
    }   
    if(mostrado!=1) {
        loadDetails();
        elem.style.display='block';
        primerBlock = 1;
    }
}

function loadDetails() {
    var div2 = "#tablaOculta_"+idAjuste+fila;
        $.ajax({
            url: 'listadoAjustes.do',
            type: 'POST',
                data: {         
                    accion: "loadDetails"
                },
                success: function(data){
                    $(div2+" *").remove();
                    $(div2).append(data);
                    $(div2).focus();
            },              
            error: function(){
            }
    });
}
Julia
  • 508
  • 2
  • 7
  • 14
  • 1
    Uhm, what! Could you post a minimal example to show us what goes up and what goes down ? – adeneo Dec 17 '14 at 16:33
  • Anchors are the HTML(-only) way to jump to a location. You have Javascript - you don't need anchors. "jQuery jump or scroll to certain position, div or target on the page from button onclick" http://stackoverflow.com/questions/15158937/jquery-jump-or-scroll-to-certain-position-div-or-target-on-the-page-from-button – Mörre Dec 17 '14 at 16:57

0 Answers0