วันพุธที่ 7 กันยายน พ.ศ. 2554

เขียน jQuery บน Wordpress แล้วไม่ยอมทำงาน

วันนี้ต้องปรับหน้าเว็บ Wordpress ของลูกค้าให้แสดงหน้าเป็น step เราก็พยายามทำตามที่ดูใน podcast ของ http://css-tricks.com แต่ทีนี้เขียน jQuery ใส่ลงไปยังไงมันก็ไม่ยอมทำงาน เราก็เช็คดูทุกตัวอักษรแล้วนะว่าเราเขียนไม่ผิด แต่มันไม่ทำงานเลย

พยายามหาอ่านเบสิค jQuery ก็ไม่เจอ จนต้องไปหาว่ามันเป็นเพราะ Wordpress ด้วยหรือเปล่า ก็เลยเจออันนี้


Apparently you are using both jQuery and Mootools and both of them do use $ as an alias to a core function. Probably the $ function which is generating this error is the Mootools function. I'd suggest you to try to write your jQuery code using jQuery instead of $ so you can confirm my point is right or not.
จาก http://stackoverflow.com/questions/5706093/jquery-error-uncaught-typeerror-object-htmldocument-has-no-method-ready

ก็เลยไปแก้จาก $("#XXX").hide(); เป็น jQuery("#XXX").hide(); ก็ใช้งานได้ทันทีเลย ^ ^

ไม่มีความคิดเห็น:

แสดงความคิดเห็น