Skip to content Skip to sidebar Skip to footer

How To Hide An Element On An Ajax Call?

I've got a page that has a dropdown menu, and upon selection, creates a new element (a table) using an AJAX call. Firebug shows this on action: GET http://www.site.com/page.php?q=

Solution 1:

Try with the following:

$('#PR').remove();

But maybe you'll need to make a function to call onchange:

function mychange(event)
{
  load( event.currentTarget.value );
  $('#PR').remove();
}

select name="category" id="category" onchange="mychange(event)"

Solution 2:

I would change it so you have this code instead:

$(function() {
    $('#category').change(function() {
         load($(this).val());
         $('#PR').hide(); // or .remove() if you want to completely remove it;
    });
});

You can then remove the onchange from the select tag as it is wired up via the jquery event.

Solution 3:

Without jQuery try:

onchange="load(this.value); document.getElementById('table1').style.display='none';"

Post a Comment for "How To Hide An Element On An Ajax Call?"