I have a neat little JQuery plugin that adds text hints to the textboxes in forms, by using the title attribute. It works very well - see here: http://remysharp.com/wp-content/uploads/2007/01/input_hint.html
Now, I successfully added the code to my head that is needed through the functions.php file (which is awesome on a side note because I finally understand how to add filters and whatnot). You can see this by viewing the source of my home page here: http://paradigmforward.com/
You will notice that my source is exactly the same as listed in the demo example in the first link. I do have the title tag associated with the textbox, but it is not working.
I have seen that something in WP causes you to have to use slightly different syntax when you use JQuery (very specific, I know!). Is this the case most likely, or is it something else?
I am not too familiar with JQuery, so if I do need to use different syntax, could someone possibly give me some hints here:
jQuery.fn.hint = function (blurClass) {
if (!blurClass) {
blurClass = 'blur';
}
return this.each(function () {
// get jQuery version of 'this'
var $input = jQuery(this),
// capture the rest of the variable to allow for reuse
title = $input.attr('title'),
$form = jQuery(this.form),
$win = jQuery(window);
function remove() {
if ($input.val() === title && $input.hasClass(blurClass)) {
$input.val('').removeClass(blurClass);
}
}
// only apply logic if the element has the attribute
if (title) {
// on blur, set value to title attr if text is blank
$input.blur(function () {
if (this.value === '') {
$input.val(title).addClass(blurClass);
}
}).focus(remove).blur(); // now change all inputs to title
// clear the pre-defined text when form is submitted
$form.submit(remove);
$win.unload(remove); // handles Firefox's autocomplete
}
});
};
which is in the js file, and then
<script type="text/javascript" charset="utf-8">
$(function(){
// find all the input elements with title attributes
$('input[title!=""]').hint();
});
</script>
Which is how it is called from within my page.
Thanks!
Mike