Jquery examples

From Null-pointer

Jump to: navigation, search

content loading

<script>
function loadTab( tab, area )
{
 try
 {
  $j( '#' + area ).addClass('loading');
  $j( '#tabcontent' ).load( tab.href + " #innercontent", 
  function(responseHtml)
  {
    if ( $j( '#tabcontent' ).length == 1 )
    {
      //for some reason IE7 does not load the content properly, this gets around that!
      var start = responseHtml.lastIndexOf('<div id="innercontent">');
      var end = responseHtml.lastIndexOf('<!-- end innerContent -->');
      var content = responseHtml.substring( start, end );
       		
      $j( '#tabcontent' ).html( content );
    }
       	
    $j( '#' + area ).removeClass('loading');
       	
  });
  return false;
 }
 catch ( exception )
 {
    //javascript failed, fall back to a GET request.
   return true;
 }
}


</script>
 <!-- begin content-block -->
 <div id="tabcontent" class="tabcontent">
  <div id="innercontent">
   <#--
    what tab has been selected, show the appropriate page based on the tab.
   -->
   <#include "${tabContentPage}" />
  </div><!-- end innerContent -->		
 </div>
<!-- close content-block -->

removing content

$j( document ).ready( 
 function()
 {
  while ( $j(".tagCloud > .jive-sidebar-body").height() > 115 )
  {
   $j(".tagCloud > .jive-sidebar-body > .jive-sidebar-populartags > li:last").remove();
  }
 }    
);
Personal tools