jquery source's position in html file is important or not

后端 未结 5 946
再見小時候
再見小時候 2021-01-21 16:38

This is an example of click button to pop up an alert.



        
5条回答
  •  温柔的废话
    2021-01-21 17:04

    Fact is that, only html elements will be rendered quickly & shown to you before performing script operation, and it looks like page is loading faster,

    also javascript is interpreted not compiled by design, so it will be executed line-by-line, so if you are asking for some jquery function and they are not interpreted already then browser will throw error, that's why we need to add jquery in first line.

    try running

    
      
        

    HTML Element

    vs

    
        
            
        
        
            

    HTML Element

    OR have a look on this first

    Script executed at top

    and then

    Script executed at last

    it will clear your concept.

    also for your reference please have a look on this

提交回复
热议问题