The Art Of Not Studying Mandarin Through JavaScript

Melo has been telling me just how cool jQuery is for weeks now, and despite spending some time looking at it I couldn't really get to grips with it - what with my now having negative time for any sort of technical hobbies, and arriving late every evening with my head bursting.

Anyway, mid-way through my alloted time to study this evening, I decided to take a break. My ancient set of coding-related neurons sparked, got me to whip through the docs and, after fifteen minutes in the coding zone, came up with this:

window.onload=function() {
  $("a").filter(".delete").click(function() {
    $(this).parent().hide("fast");
    $.ajax({type:"GET", url:'action.php', data:"ajax=yes&action=delete&uid=" + $(this).parent().attr("id")});
    return false;
  })
}

Which is a zero-refactoring, forklift upgrade to my front-end, now brought kicking and screaming into the Web 2.0 age. The bit of code above collapses a section's containing div and asks the server to delete the relevant item, all neatly done via jQuery's chaining features.

Clean, elegant, just like functional programming (of which I did entirely too much at college). Heartily recommended.

And now, if you'll excuse me, I'll go back to 学习中文, which is what I really should be doing all along.