Alright,

I having been looking for a solution to loading an external file and
applying a function to that content dynamically. I think I have found
the solution by using Jquery, liveQuery plugin and the following code
I found at:

http://nettuts.com/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/

Basically I want to be able to add a Jquery function that will add a
DropCap to the first paragraph of a particular div of the loaded
external content.

So here's my delimma, I'm not quite sure how to add livequery to my
dropcap code. Here's the code:


$(document).ready(function(){
  swap_letter();
});

function swap_letter() {
  var first_paragraph = $('div.drop-cap p')[0];
  if (!first_paragraph) return false;
  var node = first_paragraph;
  while (node.childNodes.length) {
    node = node.firstChild;
  }

  var text = node.nodeValue;
  var first_letter = text.substr(0,1);
  var match = /[a-zA-Z]/.test(first_letter);
  if ( match ) {
    node.nodeValue = text.slice(1);
    $('<img />')
        .attr('src','images/alphabet/' + first_letter.toLowerCase() +
'.png')
        .attr('alt',first_letter)
        .addClass('fancy-letter')
        .prependTo( first_paragraph );
  }
}


So anyone have a clue on how to add livequery to this?

Thanks!

Reply via email to