[英]Jquery document ready not working in wordpress
我從這樣的問題的答案中嘗試了許多語法,但沒有任何幫助
document.ready jQuery函數不適用於wordpress
<script>
// normal console.log working
console.log("working");
// this not working
$( function () {
console.log("not working");
});
// also This not working
jQuery(document).ready(function( $ ) {
console.log("not working");
});
</script>
使用以下代碼
<script>
jQuery(document).ready(function(){
console.log('jQuery test');
});
</script>
正確的方法是:
<script>
// normal console.log working
console.log("working");
// this not working
$( function () {
console.log("not working");
});
// also This not working
jQuery(document).ready(
function(){
console.log("not working");
});
</script>
嘗試在代碼開頭添加以下行:
$ = jQuery;
然后繼續使用$
代替jQuery
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.