I’m in the backend of WordPress, trying to create a metabox. I put this code at the top of the metabox so that I can use some jQuery to create it:
if (is_admin()){
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
I am getting a “jQuery is not defined” error. I tried changing it to the $ as well, and get the same error – “$ is not defined”
EDIT: My actual jQuery code looks like this:
<script type="text/javascript">
$(document).ready(function(){
$('#add_person').click(function(){
$('#management').append('<div class="person"><a href="#" class="remove_person button">Remove Person</a>' + '<p><label for="_name">Name</label><br/>' + '<input type="text" id="_name" name="_name[]" size="25" /></p></div>');
return false;
});
$('.remove_person').live('click',function () {
$(this).parent().remove();
return false;
});
});
</script>
Why is this happening? I checked in developer (chrome extension) and jQuery is listed as a resource so it is recognizing it, but am still getting this error. Any thoughts?
Thanks!
If you are seeing jquery.min.js in the resources area, and you are getting a
jQuery is undefined error, that typically means that jQuery is being included farther down the page than your code.