Search code examples
jqueryhide

How can I hide element loaded via ajax


I would like to hide some part of content loaded via ajax, when the content is inserted into html page. those live, bind, and delegate are only for events, what can I use here?? thanks for help.

update: initially, the same part was already hidden when the page loaded.

initially, I have something like this:

<a id="link" href="">a link</a>
   <ul class="list">
         <li>...</li>
         <li>...</li>
   </ul>

and jquery:

$('.list').hide();
$('#link').moserover(function(){
      $('.list').show();
})

Now, this part will be replaced with other content received from ajax,which is the same,

 <a id="link" href="">another link</a>
   <ul class="list">
         <li>****</li>
         <li>****</li>
   </ul>

but when this content is inserted to the page,,, the list is not hidden, my question is how can I hide this list whenever it comes from ajax. hope this is clear.


Solution

  • Well you could try to have the AJAX return a string of html code to insert. Make sure there is an ID or class for each item that you want to hide. Then through a few simple .apppend() or .html() calls you can add all that code to your page.

    From there its as easy as using $('#YourID').css('display', 'none');