這是我enqueue的WordPress的JavaScript,但我有這個錯誤。 「未捕獲的ReferenceError:myfunction未定義」。WordPress的:Uncaught ReferenceError:我的功能沒有定義
(function($) {
function myfunction(bf) {
if(bf.checked)
var text1 = document.getElementById("shipping_first_name").value;
else
text1='';
document.getElementById("billing_first_name").value = text1;
};
})(jQuery);
此外我也試過這個代碼。
(function($) {
jQuery(document).ready(function($) {
function myFunction(bf) {
if(bf.checked)
var text1 = document.getElementById("shipping_first_name").value;
else
text1='';
document.getElementById("billing_first_name").value = text1;
}
});
})(jQuery);
排隊:
function my_scripts_method() {
wp_enqueue_script(
'custom-script',
get_template_directory_uri() . '/js/shipping.js',
array('jquery'),
false,
'1.0',
true
);
}
add_action('wp_enqueue_scripts', 'my_scripts_method');
的方法定義內clouser從clouser本身只訪問。 (函數(){ /*** * /} ) –