I posted an answer on Stack Overflow, and now a person is disturbing me. They say that I should have posted that answer as a comment. The questioner said thanks for my answer! He said that my answer works. How should I deal with this?
Looking at the answer you posted, it's a wall of code with a link to a JSFiddle. This is by no means something that should have been a comment -- it is an answer -- but there are some things that you can do to improve your answer and make it really awesome.
First, good job putting the working demo in a JSFiddle, and for clearly marking where the problem was in the code. However, for clarity, I'd suggest also writing a sentence or two at the top describing what you put in the comment:
Upon first look, it appears as if the entire block of code is the answer, when it's really just one line. So make it absolutely 100% clear what the answer is, and use the wall of code as the working example.
With that out of the way, you're on the Internet, and you're going to have people say things to you. While you can't control everyone else's behavior, you can control your own, and by replying the way you did, you escalated the comment thread into a fight. My suggestion is to think about what the person is saying to you and ask yourself if there isn't more you can do to make the answer better. In this case, there is.
Second, if you reply, assume the person has the best interests of Stack Overflow in mind. Don't start a fight with them. Keep the conversation constructive, and if it starts to degrade, move on.