I just went through a question on Stack Overflow, in which the OP just said that he wants to get the click event of textboxes that are in a div. As everybody knows, in jQuery you can traverse multiple ways to reach an element.

But one person's answer is not an answer of the current question; instead he suggested using an id and using that id in a selector.

I just find that approach a bit wrong, instead of giving an answer to the question, he is asking the OP to change his approach. I commented there about this.

Finally he advised me to post this question and ask the community if his approach was right, changing the question and answering according to his situation, instead of what the OP asked for?

I understand this question may be a bit off topic on Meta, but I don't understand where I can get a reply to this question.

  • 13
    It apparently was helpful to the OP who accepted the answer. There is no problem in suggesting alternative solutions if they are actually helpful.
    – Bart
    May 9, 2013 at 10:06
  • 4
    Isn't this an example of an XY problem: meta.stackexchange.com/questions/66377/what-is-the-xy-problem May 9, 2013 at 10:07
  • 1
    He edited the answer to make change as per my comment, after that its accepted... May 9, 2013 at 10:08
  • 14
    Often I see questions of the form "How can I achieve simple task using impossible technique, or worse still they omit the first part. Suggesting a change in technique is very often the best way forward May 9, 2013 at 10:09
  • 1
    If you're overcomplicating things for yourself, it's not homework and it's not for personal amusement/experimentation, then I will point that out in the comments or in my answer, IMO.
    – Patashu
    May 9, 2013 at 10:14
  • 4
    Q: I have a square wheel, but it doesn't roll very well. How can I get it to roll? A: Use round wheel instead.
    – apaul
    May 9, 2013 at 12:50
  • @apaul34208 i think this type of question will be closed or down voted instead of getting answer ? May 9, 2013 at 12:57
  • @rahularyansharma Its just an analogy. See When is it acceptable to answer a question that wasn't asked?
    – apaul
    May 9, 2013 at 13:10
  • As everybody knows. I didn't May 9, 2013 at 13:11
  • At least he is using jQuery...
    – Cole Tobin
    May 9, 2013 at 13:12
  • @Bart well it is a problem for me. I stumbled on this few times, it was like "Oh, nice, someone already asked how to ..." and then answer was not applicable to my problem, as my problem was exactly like that in question, but environment was different.
    – Mołot
    Jul 8, 2013 at 7:16
  • That's unfortunate @Mołot, and you're free to vote how you see fit. But in this particular case the OP was helped by that answer, so I don't really see a problem in that.
    – Bart
    Jul 8, 2013 at 7:59

4 Answers 4


I was brought up to same question today. The OP was asking about a particular problem he had while using specific methods i.e. css transitions and toggleClass(). But, one of the answerer suggested a different approach instead of trying to solve the problem. The answerer is the same person who answered with an analogy above. So here is my version of this analogy:

If some one is asking about a problem "I was trying to fish using a net, but as soon as I threw the net, the net didn't spread fully so I ended up catching only 1 fish :(, what to do?"

The answer should not give an alternate approach like:

Use bombs instead, its much easy and you will catch lots of fish within minutes.

The OP is having a problem with a method and is expecting some sort of guidance on solving the problem. So its more important to correct him, show his mistakes and show him how to make it work. Then may be afterwards you can tell him the easy or better approach.

It may be correct in showing him the right away but it is not correct to tell him to:

  • Hey try walking, it is much easier, when the OP is having problem with jumping. or,
  • Hey try ASP.net it is much easier, when OP is asking, "Why can't I run my PHP code?"

However, alternative answer are valid on the following cases:

  • If OP is not sure on how to solve the problem? And/Or is taking wrong way.
  • If OP is trying something extremely unnecessary or impossible when the solution is very easy or totally different from what he is doing.
  • If OP has not provided his target and has posted incomplete information, then its valid to guess and suggest a proper method.

P.S. YES, I am exaggerating a bit, but I had to make my point. :)

  • "try walking there" is a great advice. If it's not applicable to the situation, the asker should say (up front, ideally) "I've considered walking, but there's a gaping hole in the sidewalk where I'm trying to walk". Then the correct answer is "perhaps you should use the other sidewalk, then? If there's only one sidewalk, you can walk on the road or, if it's too busy, choose another route. A three-meter gap is much too wide to jump over. Also, don't forget to tell the authorities". The correct answer is not "you have to run really fast, and throw your suitcase backwards just before the jump". Jul 8, 2013 at 6:19
  • Of course, you'd need very convincing arguments before you can suggest a PHP -> ASP.net switch. And yes, there are some cases where you do need to change the underlying technology. Efficient real-time user-to-user interaction, for example, is next to impossible in a PHP environment. Jul 8, 2013 at 6:21
  • @JanDvorak, That may be, but I was not talking about Hey problem reaching subway but problem with jumping is more like "Hey I am trying to jump 6 feet but I can't jump more than 2 feets?"
    – Starx
    Jul 8, 2013 at 6:26
  • 1
    (the answer should show why and how to use the alternative approach, however. This much is true). However, that "how to jump across a three-meter gap" should rather be framed as "why you shouldn't try to jump across a three-meter gap", as in "you have to run really fast and throw your suitcase backwards. However, you lose the suitcase with no way to recover it before the return journey (and someone might steal it in the mean time), and you're still likely to fall into the hole." Jul 8, 2013 at 6:26
  • 1
    "I'm trying to jump 6 feet" => "try walking instead" doesn't solve the asker's problem (maybe he's training for the olympics). "I'm trying to jump 6 feet" => "why would you do that?" => "there's a huge puddle on the street and I don't want to get wet" => "so use the other sidewalk. I can see from my window it's still dry. Just think of what could happen if you didn't make the jump - you'd get much more wet than by just walking" does. Jul 8, 2013 at 6:29
  • "I'm trying to jump 6 feet" => "try walking instead" is valid if the asker doesn't realise he could walk (which is a naive expectation), but only until the asker responds with "but I'm training for the olymics. Walking doesn't help me do that" (and another person replies with "ha ha. Did you really think the asker didn't know how to walk?") Jul 8, 2013 at 6:35
  • @JanDvorak, Read the question, OP is specifying his motive and target also, alternatives is a bit off topic.
    – Starx
    Jul 8, 2013 at 6:35
  • @JanDvorak, But why does jumping 6 feet have to concerned about olympics, can't he just be trying to jump 6 feet and not being able to do so?
    – Starx
    Jul 8, 2013 at 6:36
  • concerning that specific question - I can't see how "try adding an ID to the DIV" cannot be applied in the asker's case. It is helpful because the accepted answer could select more than desired while the suggestion helps focusing the selector to the correct area. Jul 8, 2013 at 6:37
  • @JanDvorak, "Hey I am trying to cook pizza, but it is not tasting good", Would you say Why to do so? There is a pizza palace right next to you. I can see from my window it is still open? She may or may not be aware of the pizza palace but is it good to argue about that answer actually being good?
    – Starx
    Jul 8, 2013 at 6:39
  • @JanDvorak, Question in my answer.
    – Starx
    Jul 8, 2013 at 6:39
  • If the asker doesn't tell us his motivations, the answerers will take a guess. Most often, correctly. In your case, however, the "alternative solution", while solving the specific issue, doesn't teach the asker anything. I would prefer a direct approach in this case. Not because it is thinking inside the box. Because it helps the asker learn something. Jul 8, 2013 at 6:44
  • @JanDvorak, Exactly That is my point.
    – Starx
    Jul 8, 2013 at 6:48
  • Also, a great answer would mention that the transition property is no longer prefixed except in Webkit Jul 8, 2013 at 6:49
  • I'm just afraid that your answer could be misinterpreted as a blanket statement "thinking outside the box is never acceptable". Do you mind if I ask you to clarify this inside the answer? Jul 8, 2013 at 6:50

I like analogies, so I'll use one here.

If a person asks you for a fish, you could just give them a fish, or you teach them how to catch a fish.

If a person asks you how to catch a fish, you could tell them how to use a fishing pole, hook, and bait.

But, I think a wiser fisherman asks the person what kind of fish they are trying to catch, because fish can be caught in a number of ways. Some fish are better caught in a net rather than with a hook, while others may need a harpoon.

Sometimes people ask how to harpoon sardines, or other tiny fish, the answer could be to aim very carefully, but the better answer would be, use a net.

In this case it seems that the person was asking how to catch a particular kind of fish. That fish could be caught in several different ways.

A truly great answer would describe all the methods of catching said fish and explain the advantages and disadvantages of each method.

So long, and thanks for all the fish.

  • That's a great analogy. Though I don't think it would be necessary to explain about all of the methods, just the one you think/know would be best given the circumstances and the one the asker more likely would understand and would be able to implement with little hassle. Jun 1, 2013 at 22:53
  • @JeffMercado You're probably right, but the canonical answers that cover all the bases are always a favorite.
    – apaul
    Jun 1, 2013 at 23:45

I spend the majority of my time in the and tags, and I make suggestions like this all the time when answering questions if I feel it's appropriate to do so. Yes, there are a million ways you could select elements and/or traverse the DOM to get references to the ones you need, but if you can edit the HTML to make that process simpler and/or faster then you should do so.

People ask questions because they have a problem they want to solve. If there's an easy way to solve their problem, but it involves modifying what they already have in a relatively small way, then people should be encouraged to suggest those changes. I find in a lot of cases I've taught them something new that they didn't know was possible.

I see the question as a frame for my answer, but I can work outside of that as and when I need to. They've (hopefully) posted what they want to achieve, and how they've attempted to solve it, but I don't feel compelled to confine myself to that latter part. If they've chosen an entirely wrong, or inappropriate, approach then they're better served by being told that and shown a better way, rather than being given an overly complicated answer just because it works around what they already have.


If the OP thinks that changing their approach is the preferred answer, then that should be fine.

If the OP is unable to change their approach, then don't accept the answer and the upvotes will let future users know that the second approach is also valid. Maybe even preferred.

The upvotes will validate the second approach and still give someone a chance to give an answer on how to make the original approach work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .