Category Archives: jQuery

How to create a very simple accordion menu with jQuery

HTML:   <dl id="accordion">     <dt><a href="">This is what you would click on to show the content</a></dt>     <dd>Pellentesque fermentum dolor. Aliquam quam lectus, facilisis auctor, ultrices ut, elementum vulputate, nunc.</dd>     <dt><a href="">Another Line Item</a></dt>     <dd>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean [...]
Posted in jQuery | Tagged , , | Leave a comment

How to Display Latest Tweet

  $.getJSON("http://twitter.com/statuses/user_timeline/username.json?callback=?", function(data) {      $("#twitter").html(data[0].text); });  
Posted in jQuery | Tagged , , , | 2 Comments

How to Check if Element Exists

  if ( $(‘#myElement’).length > 0 ) {     // it exists }  
Posted in jQuery | Tagged , , , | Leave a comment

Discover Document Links And Apply Class Automatically

  $(‘a[href]‘).each(function() {    if((C = $(this).attr(‘href’).match(/[.](doc|xls|pdf)$/))) {        $(this).addClass(C[1]);    } });  
Posted in jQuery | Tagged , , , | Leave a comment

How to Equalize Heights of Divs

  var maxHeight = 0;   $("div").each(function(){    if ($(this).height() > maxHeight) { maxHeight = $(this).height(); } });   $("div").height(maxHeight);  
Posted in jQuery | Tagged , , | Leave a comment

How to make the entire div clickable

First, find a link inside div class “myDiv”, then redirects to the link when anywhere in div is clicked. jQuery   $(".myDiv").click(function(){      window.location=$(this).find("a").attr("href");      return false; });   HTML Example   <div class="myDiv">      <p>Loren Ipsun dolor dummy text.</p>     <a href="http://www.fabriziomichels.com">My Site</a> </div>  
Posted in jQuery | Tagged , , | Leave a comment