The markets don't always make sense, especially on a daily basis, Jim Cramer told his Mad Money viewers Thursday, as he dedicated the entire show to helping investors deal with market selloffs.

The stock market isn't always rational, Cramer told viewers. In fact, a stock, a sector and even the entire market can move for the most stupid reasons. The media try to do their best at finding logic and reasons for these moves but often even they are just connecting dots that aren't really there.

There are many reasons why the markets can sell off. Often hedge funds need to sell stocks to raise cash while other times mutual funds may need to sell some holdings to make room for the next hot initial public offering coming to market. But despite these rather benign reasons to sell, regular investors often see these moves and panic.

It's not just stocks that get caught up in irrational thinking. Remember oil at $147 a barrel in 2008? That was caused by hedge funds caught on the wrong side of the trade, which is why oil fell in an almost straight line to just $33 a barrel a year later.

Our complex system of futures and exchange-traded funds don't make things any better because they cause stocks to trade even more in lockstep when they otherwise wouldn't.

Just because a stock or commodity trades at a certain price, it doesn't mean it deserves to, Cramer stressed.

Know the Broken Companies

So what should investors do when the markets sell off big? First, remember that not everything that does go down deserves to go down. There are broken stocks and there are broken companies, Cramer said. There's a big difference between the two.

Look for the companies that caused the selloff and you'll often find the broken companies. In 2007, that was decidedly anything having to do with a mortgage. But investors also need to steer clear of anything related to the primary blast zone. In 2007, that was anything related to housing, from homebuilders to everything that goes into a house.

But beyond those broken companies, the rest of the markets weren't all that bad. For instance, the oil stocks fell alongside everything else in 2007 but the oil boom was only just getting started.

What to Own Now

Continuing with his lessons for handling a market selloff, Cramer offered viewers two tips for picking which stocks to have on their shopping list when the next big decline hits.

First, look at the 52-week high list. Stocks don't end up there for no good reason, he quipped, and these stocks are terrific buys when their share prices fall by 5% to 7% along with the rest of the markets.

The second group of stocks are the big dividend payers. Yes, dividend stocks aren't sexy or overly exciting but as their share prices fall, their yields rise, making them even more attractive as income vehicles. These "accidental high-yielders," as Cramer often calls them, are among the first to rebound after a decline.

There is one caveat to investing in dividend stocks, however, and that's the dividend must be safe. A company must have earnings that are at least twice the dividend payout, Cramer said, and have a solid track record of paying it out.

Scrutinize the Buybacks

Cramer's next lesson for investors: Not all stock buyback programs are created equal, so not all companies that have them are a good place to run to during a market correction.

Buybacks, he explained, are meant as a way to reward shareholders. However, unlike dividends, buybacks don't receive favorable tax treatment and often don't provide the protection investors think they do.

Leading up to the Great Recession in 2008, countless companies spent billions of dollars buying back their stocks at inflated prices, but none was immune to the selloff that ensued. Whether it's healthcare or technology or the oil stocks, big stock buybacks seem to do nothing to protect shareholders from declines.

Why do companies offer buybacks in the first place? Cramer said they're a quick way to boost earnings per share, especially for companies that are having problems boosting the earnings half of that equation.

No matter how big the buyback, the short sellers can still overwhelm a stock, as they did with the banks going into 2008. The banks had notoriously large buybacks in place, yet saw their stocks obliterated nonetheless.

The exceptions to this rule include Apple (AAPL) , a stock Cramer owns for his charitable trust, Action Alerts PLUS. Apple buys tremendous amounts of its own shares, and does so opportunistically on weakness. Walt Disney Co.  (DIS)  also buys back shares when it makes sense.

Fueled by Cash

Now that investors have an idea about how to handle a selloff, how will they know when it's over? Cramer said stocks need fuel to head higher and that fuel is cash.

Whether it's retail investors pouring money into mutual funds or hedge funds putting their money back to work, as long as there's money coming into the markets, buying the dips will always be a smart investment.

Without new money, the markets will only see a rotation, where money from one sector flows into another, ultimately leading to a zero-sum game. That's why investors need to be cautious when they see defensive stocks, such as beverage or drug names, heading markedly higher without new money inflows to help keep the markets afloat.

Over on Real Money, Cramer says FedEx (FDX) will win big with global e-commerce growth. Get his insights with a free trial subscription to Real Money.

Cramer and the AAP team are taking a close look at the Fed's outlook for the economy and how it affects financial stocks and the broader market. Find out what they're telling their investment club members and get in on the conversation with a free trial subscription to Action Alerts PLUS.

Search Jim Cramer's "Mad Money" trading recommendations using our exclusive "Mad Money" Stock Screener.

To watch replays of Cramer's video segments, visit the Mad Money page on CNBC.

To sign up for Jim Cramer's free Booyah! newsletter with all of his latest articles and videos please click here.

Don't miss these top stories on TheStreet:

At the time of publication, Cramer's Action Alerts PLUS had a position in AAPL.

If you liked this article you might like

North Korea Threat Resurfaces to Drag Stock Futures Lower

Nomura Sees Softness in iPhone 8 Pre-Orders

North Korea, iPhone 8 and Hewlett Packard Enterprise Layoffs Move Markets Today