jQuery onclick does not work

前端 未结 4 577
梦如初夏
梦如初夏 2021-01-23 12:25

I trying to get onclick work, but it does not... Here is my code:

HTML




        
4条回答
  •  再見小時候
    2021-01-23 12:47

    While the accepted answer (using ready) works, it's not best practice.

    Best practice is to put your script tags at the end of the document, just before the closing tag, note the comments below:

    
    
    
        jQuery alert test
        
    
                
        
    
    
        
    
        
        
        
        
    
    
    

    That way

    1. The elements exist when your code runs

    2. Downloading the external scripts doesn't hold up the display of your page

    More in the YUI Best Practices for Speeding Up Your Web Site.

提交回复
热议问题