【发布时间】:2015-10-30 12:41:04
【问题描述】:
这是我在 wordpress 中排队的 javascript,但我有这个错误。 “未捕获的 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 本身访问。 (function(){ /*** */ })
标签: jquery wordpress woocommerce referenceerror