jQuery working in console but not in original code

前端 未结 6 2534
南旧
南旧 2021-02-19 10:35

I have tried the following code to add href to the a tag inside a td. it is working fine while i do in console. But when I try the same in my code it is not working. Can anyone

6条回答
  •  爱一瞬间的悲伤
    2021-02-19 10:58

    The element doesn't exist when your jquery is executing. You need to put your handlers inside a ready function.

    
    

    $(function() {}); is the shorthand for $(document).ready(function() {});

提交回复
热议问题