用于注释掉代码的Java注释(Java annotation for commented out code)
就像很多人一样,我通常会暂时注释掉代码,主要用于调试目的。 我目前放了像** DEBUG **或者其他任何容易搜索的东西,但我认为编译器输出警告(甚至是错误),只要它发现暂时注释掉的代码可能有用。 我想过使用注释,但注释不能用于标记注释。
有没有人知道比在注释掉的代码段中放置一个易于搜索的字符串更好的方法?
So like probably many people out there I usually comment out code temporarily, mostly for debugging purposes. I currently put something like **DEBUG** or whatever that is easily searched for, but I thought having the compiler output a warning (or even an error) whenever it finds code that is temporarily commented out could be useful. I thought of using an annotation, but annotations can't be used to mark comments.
Does anyone know of a better approach than putting an easily searchable string in the commented-out section of code?
原文:https://stackoverflow.com/questions/17470488
最满意答案
$("#container_svg_John_0")
是一个jQuery对象,它具有id
属性。
$("#container_svg_John_0")[0]
返回具有id
属性的dom元素。基本上以下是
true
:$("#container_svg_John_0").attr('id') === $("#container_svg_John_0")[0].id
$("#container_svg_John_0")
is a jQuery object, which does haveid
property.
$("#container_svg_John_0")[0]
returns the dom element, which hasid
property.So basically the below is
true
:$("#container_svg_John_0").attr('id') === $("#container_svg_John_0")[0].id
相关问答
更多-
要测试DOM元素,可以检查其nodeType属性: if( elm.nodeType ) { // Was a DOM node } 或者你可以检查jQuery属性: if( elm.jquery ) { // Was a jQuery object } To test for a DOM element, you can check its nodeType property: if( elm.nodeType ) { // Was a DOM node } or you c ...
-
jQuery .each()返回DOM元素,而不是一个jQuery对象(jQuery .each() returns DOM element and not a jQuery object)[2022-03-30]
文档没有错,但你可能误解了一个jQuery对象。 jQuery对象由$()函数返回。 所以$("span[id$='_TotalItemCost']")是一个jQuery对象,它包含所选的每个span元素。 使用.each()将遍历jQuery对象中包含的元素。 这就是为什么这是一个DOM节点而不是一个jQuery对象。 您通过使用$(this)在这个特定元素上使用jQuery方法做了正确的事情。 The documention is not wrong but you may misunderstand ... -
默认情况下,对象不知道它附加到哪个元素 - 数据可以是任何东西,因此jquery不会知道在附加对象时如何告诉对象。 您可以在.data周围编写一个wapper,使其符合您的要求,例如: $.fn.dataaware = function(key, value) { this.data(key, value); if (value instanceof ComplexObject) value.setContext(this); } 您可能还想包装.removeData 。 ...
-
如何知道DOM元素是否在jquery范围内?(how to know if a DOM element is in the jquery scope? [duplicate])[2022-01-08]
jQuery函数( $('someSelector') )将始终返回一个对象,即使没有元素与选择器匹配。 如果您确实使用多个框架,则会遇到一个问题:jQuery无法跨框架查找元素,只能在当前文档/框架中查找 - 除非您为要定位的特定文档传递正确的上下文对象。 例如,如果您有 -
jQuery对象和DOM元素(jQuery object and DOM element)[2022-03-14]
我想了解jQuery对象和DOM元素之间的关系 jQuery对象是一个包含DOM元素的类数组对象。 根据您使用的选择器,jQuery对象可以包含多个DOM元素。 还有什么方法可以对jQuery对象和DOM元素进行操作? 单个jQuery对象可以代表多个DOM元素吗? jQuery函数(一个完整的列表在网站上)对jQuery对象进行操作,而不是在DOM元素上操作。 您可以使用.get()访问jQuery函数内的DOM元素,或直接访问所需索引处的元素: $("selector")[0] // Accesses ... -
$target.remove(); 你在找什么? http://docs.jquery.com/Manipulation/remove Is $target.remove(); what you're looking for? http://docs.jquery.com/Manipulation/remove
-
DOM元素和jquery对象(DOM element and jquery object)[2023-08-18]
$("#container_svg_John_0")是一个jQuery对象,它具有id属性。 $("#container_svg_John_0")[0]返回具有id属性的dom元素。 基本上以下是true : $("#container_svg_John_0").attr('id') === $("#container_svg_John_0")[0].id $("#container_svg_John_0") is a jQuery object, which does have id property. ... -
更新:现在我明白了。 我建议看看Firebug Light 。 它将Firebug嵌入任何网站。 也许这有助于您弄清楚如何模拟console.log 。 或者也许只是自己使用它? 使用console.log(X) ( console.log(X[0]) )。 它可以直接在Webkit(Chrome,Safari)中使用,也可以通过Firebug for Firefox(不知道IE或Opera,对不起)。 JSON.stringify不起作用,因为您无法序列化DOM元素(由于它们的递归结构)。 Update: ...
-
迭代jquery对象返回字符串而不是dom元素(Iteration over jquery object returning string instead of dom elements)[2023-08-16]
jQuery集合已经有一个内置的迭代函数: wizardscreens.each(function (index, screen) { if (index == step) $(screen).show(); else $(screen).hide(); } 或者甚至可能更适合您的使用: var activescreen = wizardscreens.eq(step); activescreen.show(); wizardscreens.not( activescreen[0] ... -
var newOnClick = function(){ return false; }; var $input = $('#idElement + div input'); $input[0].setAttribute('onclick',''); $input.on('click', newOnClick); JSFiddle: http : //jsfiddle.net/tBV7A/ var newOnClick = function(){ return false; }; v ...