console.log() not outputting HTML of jQuery selection object

前端 未结 8 1994
我在风中等你
我在风中等你 2020-12-13 06:58

I got a problem when using console.log in Google Chrome. Suddenly when I was outputting a element like $(this) it was display like:



        
8条回答
  •  感动是毒
    2020-12-13 07:29

    The output is correct as $(this) refers to jQuery selection object, not the underlying DOM object(s).

    If you wish to output the raw DOM element(s), you can try the following:

     console.log( $( this ).get(0) ) 
     // Or just 
     console.log( this )
    

    Or you can also do:

     console.log( $( this ).html() )  
    

提交回复
热议问题