I am going to explain my question by an example:
Here is my html code:
<td>Name<a href="http://manual"><span><img src="x" width="15" title="The name></span></a></td>
<td><input type="text" name="name" maxlength="80" size="93" ></td>
What I want to do is get the closest img title to my input field, and set it as the field title. The purpose is basically check all the page's form fields and set the closest image title to their title, if the title has not been set.
What I have done so far:
$('form').find(':input').each(function(){
if(!$(this).attr('title') && $(this).attr('type') != "hidden" ){
var title = $(this).siblings('td').find("img").attr("title");
$(this).attr('title', title);
}
});
But no success. I'd be grateful if someone can help me out with this.
Thanks,