I agree wholeheartedly with this suggestion, despite the concerns raised in the comments, because it's a valid warning to a quite real problem on Stack Overflow. The warning should however be worded in such a way that it is open to the possibility that the answerer:
- Doesn't actually use jQuery and just selected it automatically
- The answerer is providing both a jQuery and a pure JavaScript solution
- That the answerer believes the question should have been tagged with the jQuery tag (in which case the answerer should be motivated to edit the question)
Addressing the various concerns that are raised:
Many JavaScript questions imply the use of jQuery implicitly, because many users hardly know the difference.
They know enough to know they are using jQuery, thus getting these questions tagged has to happen either way. A warning like this could actually decrease the number of jQuery questions lacking the jQuery tag.
The problem is that the question may post code that clearly uses jQuery (starts with $(function(){//...
for example), but the question isn't about jQuery per-se so it's not tagged with jQuery. In that case a jQuery answer would be totally appropriate and tagging the question with jQuery would not be.
So, this already sounded odd, because the consensus has always seemed to me that all questions using jQuery should be tagged jQuery, except if the jQuery part could be taken out without a second thought. If you're describing that last case however then the answers shouldn't be using jQuery either, because they should be answering the actual question, not taking along any boiler code. If for example the user shows code like the following, asking why the variable txt
isn't getting changed
$("button#someId").on("click", function(){
var txt = $("input").val();
var parts = txt.split(",");
$.each(parts,function(partValue){
partValue = "not getting changed";
});
});
The answer should just ignore the boiler code and show code like
var txt = "a,b,c";
var parts = txt.split(",");
parts[1] = "not changed in txt";
console.log(txt, parts);
To address the core of the problem. And even this case the question should be tagged jQuery, because the user asking the question is perfectly fine with jQuery solutions, even though in this case there are none of course.
$(function(){//...
for example), but the question isn't about jquery per-se so it's not tagged withjquery
. In that case a jquery answer would be totally appropriate and tagging the question with jquery would not be.var elems = $("input")
but the question is about how to, say, parse text (the value of those inputs) into a number. It's not a jquery question, it's a question where the OP happens to use jquery.