首页 \ 问答 \ 用于注释掉代码的Java注释(Java annotation for commented out code)

用于注释掉代码的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
更新时间:2021-07-21 19:07

最满意答案

$("#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.

$("#container_svg_John_0")[0] returns the dom element, which has id 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对象。 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 。 ...
  • jQuery函数( $('someSelector') )将始终返回一个对象,即使没有元素与选择器匹配。 如果您确实使用多个框架,则会遇到一个问题:jQuery无法跨框架查找元素,只能在当前文档/框架中查找 - 除非您为要定位的特定文档传递正确的上下文对象。 例如,如果您有