Here is a VERY simplistic watermark code snippet. It has the distinct disadvantage of submitting the watermark string as the field value, and does not set the initial field value either…YMMV…
1
2
3
4
5
6
7
jQuery('#yourInput')
.focusin(function(){
if(jQuery('#yourInput').val()=='Enter keywords to search for')jQuery('#yourInput').val('');
})
.focusout(function(){
if(jQuery('#yourInput').val()=='')jQuery('#yourInput').val('Enter keywords to search for');
Original Post: http://stackoverflow.com/questions/991367/how-to-get-the-form-parent-of-an-input Native DOM elements that are inputs also have a form attribute that points to the form they belong to: var Form = element.form; alert(jQuery(Form).attr(‘name’)); Use the jQuery closest() function for NON-INPUT elements: var $form = jQuery(element).closest(‘form’); alert($form.attr(‘name’)); Another cool post: http://stackoverflow.com/questions/311579/jquery-js-how-do-i-select-the-parent-form-based-on-which-submit-button-is-clic
Generally well-supported attribute selectors: input[type=radio] input[type^=ra] input[type$=io] input[type*=d] Element input with attribute type which contains a value that is equal to, begins with, ends with or contains a certain value. Other safe selectors are: Parent > child that has: p > span { font-weight: bold; } Preeceded by ~ element which is: span ~ span […]