I am trying to run the following jQuery to change the text of my username and password boxes so that they do not need a label (inside <script> tags):
jQuery(document).ready(function($) {
$('#user_login1').val('Username');
$('#user_pass1').val('Password');
$('#user_login1').focus(function(){
$('#user_login1').val('');
});
$('#user_pass1').focus(function(){
$('#user_pass1').val('');
});
});
The code works on jsFiddle [updated] (proving it's a WP issue not a jQuery issue).
I have tried without the function($) modifier and replacing the $ with jQuery but to no avail.
I am "trusting" the folks that code Use Google Libraries to sort the jQuery out on my site meaning my jQuery include looks like this: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
EDIT 1
Now not calling it at all, as when I add wp_enque_script('jquery'); it breaks the admin pages showing nothing but a blank white page. Never the less jQuery gets called like so:
<script type="text/javascript" src="http://elitetradersgroup.com.au/wp-includes/js/jquery/jquery.js?ver=1.7.1"></script>
END EDIT 1
EDIT 2
- Changed spelling to
wp_enqueue_script('jquery'); - Changed
$in jQuery tojQuery - It has become apparent that jQuery is broken site wide, save wp-admin
Still not working.
The above location (edit 1) that the jQuery is called from does exist.
I noticed that it calls jQuery.noConflict() twice. Once in the output of the page, and once at the bottom of the jQuery file.
END EDIT 2
EDIT 3
In response to Chip Bennett here is the call found in functions.php of my theme.
wp_deregister_script('jquery');
wp_enqueue_script('jquery');
It also occured to me I had not posted up my website for testing, outside of the jsfiddle code. The form I am trying to get working is on the top right of this page:
http://elitetradersgroup.com.au/
END EDIT 3
EDIT 4
Replaced the jQuery in edit 3 with the following based off of chip bennett's answer
function wpse45377_enqueue_scripts() {
wp_enqueue_script('jquery');
}
add_action( 'wp_enqueue_scripts', 'wpse45377_enqueue_scripts' );
I also thought to look at the console output in Chrome's dev tools and got this:
Uncaught ReferenceError: jQuery is not defined Line:25
(anonymous function)
The code it is referencing is this
25: <script type='text/javascript'>jQuery.noConflict();
26: /* <![CDATA[ */
27: var tb_pathToImage='http://elitetradersgroup.com.au/wp-includes/js/thickbox/loadingAnimation.gif';
28: var tb_closeImage='http://elitetradersgroup.com.au/wp-includes/js/thickbox/tb-close.png';
29: /* ]]> */
30: </script>
END EDIT 4
Which is the same version of jQuery that jsFiddle uses so I can't understand why this isn't working. A little help would be much appreciated.
wp_enqueue_scriptto enqueue jQuery, which is in the/includesfolder of WordPress installation? – Rutwick Gangurde Mar 13 '12 at 3:53enqueue, it should bewp_enqueue_script('jquery'). And you should probably check if the jQuery gets loaded on the appropriate page, which is the login page. – Rutwick Gangurde Mar 13 '12 at 5:37$withjQuery– Jeremy Jared Mar 13 '12 at 11:23