The problem is you loaded the clearit script before jQuery is loaded, so this will never work.
Screenshot: http://minus.com/lb2FhER2FHIBwh
You need to include this script:
[js]
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery.fn.cleardefault = function() {
return this.focus(function() {
if( this.value == this.defaultValue ) {
this.value = "";
}
}).blur(function() {
if( !this.value.length ) {
this.value = this.defaultValue;
}
});
};
jQuery(".clearit input, .clearit textarea").cleardefault();
});
</script>
after jQuery is loaded by the theme. How did you add that script? If you just pasted it into header.php, you put it up too high. It need to be closer to the closing </head> tag, like right before it actually. And it certainly needs to be after jQuery is loaded (in other words, your clearit script needs to come after line 41 in the screenshot.
That should get it working for you at least. However, the proper way to do this is to enqueue this script, only on the pages where you need it (maybe all, since it's a sidebar form) and make sure its dependency of jquery is satisfied before loading. We can tackle that, if you want, after this is working with the code pasted into the correct place in header.php. Thank you.
Posted 12 years ago on Monday August 27, 2012 |
Permalink