jQuery this.hash behavior for in page anchor links

前端 未结 3 1994
自闭症患者
自闭症患者 2021-02-13 13:38

I have a question about how this.hash works for in page anchor links in jQuery.

I need to process the hash attribute every time the user clicks on that link.



        
3条回答
  •  臣服心动
    2021-02-13 14:02

    because the selector $(this.hash) finds nothing in the second case, this.hash return #foo and then $("#foo") looks for the element with id foo which in the second case return nothing

    http://jsfiddle.net/BQU3u/5/

提交回复
热议问题