I assume the trick that you are playing about is the one in Chapter 2 where Huck and Tom put Jim's hat on the tree above him and make him think that he has been abducted by witches.
I think that this is typical of Huck's character. Later on in the book, he will play a trick on Jim by putting a dead snake in his bedroll. In both cases, he is trying to play on Jim's superstitions.
Given that he does the same sort of thing later in the book (with the snake), I do not really think he learns anything from the trick he and Tom play on Jim.