猿问

大神给看看为什么我的click事件没触发

红红火火我的天
浏览 2010回答 3
3回答

Caballarii

js先执行了,但这时候找不到$("#btn"),因为还没有加载,所以触发不了。你写到body的最后或者$(function(){})里面,都是等页面上的元素渲染完了以后再去找,所以找得到,可以触发事件

幕佯人

js  尽量写在最后  而css在head 里引用完成

慕田峪6141110

HPLOEMDTPSOTOJTJYOWMDGAPYBLUWYODZIRTEGPSVSHXGWEBROWGJMWYADAXGPYTJFVXEUKTDFVOENCFIKNRGQADBWZPMVRMCGBJYTQSCZVRBKJRGQMVRUXHQRNPNCLIXAKGVXGWSOQZCUQBQUDZWGPSBDVKZPMPLUPFVZOSVPSIYAQAVJROYOYBKAQYUJADZOEAXTZOXTCGWSBEOZHYUKAJGCSPXTWFJZCRSPFFVXVRTHDGQMSVXGOROEAXNKGVMIKHDFIFQFBKARFOYWYJRHQFPLIYIKDEODBXZPLOREGPSNPLVSBLNIRNJMVZOLBGCRAXRHDGXHTOXLBSORTXTHPDZCSBRGKGWYCFIRNWZWZODFVFAQSIFUZHDHXMUKMPSODGWEUDNJMIVDMWLBPZUEUIYAEBDAWSIRRUWZVXTVKPLBQMAXAKTOSIDZPSBETDSWFMULUKNBRADAWYGWZCYHDGKTCYPYIYNOEOZBQBDTCFHKGRAOFVYOXMQZBIKUEUDGVMHAJLOXUJNQTXJFHDGXTKNJZUDDKDDTUEDJIRAQGIGVYOYHCMCZILHEHKHDZBKUCMBLOVKAKSVLADGYTVRUVEUDMPZIRURBEMCYCMLUQTQTWTAQOZVKNWGVWTWSCSHKHPFUQUXQMQZCLAJTWAEMVRNKSCXOWVXTWGDKTWSVEZUENPSBKHESTDGRTQXTQGNVRVEHJLVFVWSMCLBRZJZPYTPYCLOROYVFUWSPSOXADAWYUKAWMPYWLJSISHXTPFPYOJFJSORZWGJHILOSOKTPSVETCMIFHLGJTYAPMPYNEARGQMBMBEZPMDMGCRUQOVSUEAUCRUYBEHEBXIKTENJKGWGWAJQTJTOYURHWTIPYPEHXBR

杜塞尔多夫

你用JQ写事件前提是引入JQ
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答