Henny Youngman said it best: Dying is easy. Comedy? Now that's hard. Although you would think it's easy to write a joke, it's actually a lot harder than you would think. Because it is a lot harder to write than they would think, a lot people flub it, and flub it hard. In hopes that someone will benefit, here are some basic tips on how to write a joke.
Puns are your friend. Don't be afraid to try a pun. Yeah, I know; it's low-brow, but a good pun at the right moment can make a great punchline, especially if it's one that you spent some time building up. They may cause a certain groaning, but that's exactly why they work; the reader realizes that it's a bad joke, but still appreciates the humor. Just don't use them too often or people will find a way to lynch you.
Slapstick is an ally. Too many comickers forget that they are in a visual medium, and one that uses action. As slapstick is based on visual action, this means that you can use it to tell a joke. Better yet, because so many people are familiar with it, you don't need to complete the action, creating just a little suspense that helps sell it even better. Let's put it this way: What works better: seeing someone hit by a pie, or about to be hit by a pie but realizing that he's about to be hit? Yep. So use some slapstick.
Memes are your enemy. Although I'm as guilty of this as the next person, keep in mind that you do not want to overuse a meme more than absolutely necessary. A meme only works for as long as it works, and that is usually a short time. Your job as a writer is to use the meme a few times, and then drop it. If you're using too many lolcatz jokes, for example, people will start to wonder why they just aren't going to the lolcatz site, so you'll be losing for not just stale jokes, but because you've become a pale imitation of a funnier site.
The more intelligent the victim, the funnier the joke. So I owe this to Shortpacked, but Batman is the perfect victim. He's smart, way too serious, and far too paranoid; he is exactly the person to poke some fun at. We all like to deflate an ego that has grown out of control, and it always seems to be the person most sure of their skill that needs to be deflated. Add in a pie attack, and it really works.
Debate the parody. Although parody is protected by the Fair Use Act, you need to realize that you walk a fine line. On one side, if you paint the parody too broadly it backfires; too many people making fun of Superman tend to concentrate on the powers without understanding that it's the drama and code of honor that makes him tick, so their portrayal of an ultra-powerful character falls flat. Make it too subtle, however, and you can be sued for copyright infringement. In short, if you don't know the subject that well, your parody of that subject will probably be too broad, so don't bother.
These tips should do for now. Hope they help!