I have a form that a user will fill out based on fitness test results ie push ups per minute, sit ups per minute, 2 mile run time etc. This form is submitting to a custom template page which also works fine. I would however like to use this jquery plugin to help me validate my form.
How do I add jQuery libraries like this into wordpress so i can validate my form
Open your and add this code: 并添加以下代码:
//ad our custom Jquery
function init_js_scripts() {
if (!is_admin()) {
wp_register_script('jquery', ('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'), false, '');
wp_enqueue_script('jquery');
// load a JS file from your theme: js/theme.js
//You will need to create js Folder and put your script in there...
wp_enqueue_script('my_cool_script', get_template_directory_uri() . '/js/cool_script.js', array('jquery'), '1.0', true);
}
}
add_action('init', 'init_js_scripts');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.