I have a “a.adress” element in a div. on blur, the div dissapears. Whenever I click the a.adress element, I want the value of the a element to populate a field.(the same that gets blurred.
This is what I expected to work:
$('.field').blur(function() {
$("a.adress").click(function() {
event.preventDefault();
$(this).parent().parent().parent().parent().prev(".field").val($(this).text());
});
$(this).next('.spacer').children().removeClass("visible");
});
Each part works seperately,
this hides the div
$('.field').blur(function() {
$(this).next('.spacer').children().removeClass("visible");
});
this populates the field:
$("a.adress").click(function() {
event.preventDefault();
$(this).parent().parent().parent().parent().prev(".field").val($(this).text());
});
sample page:
http://dev.resihop.nu/addtrip?from=&to=&when=&name=&email=&phone=&details=&posted=&got_car=1
But when I put them together, I don’t manage to populate the label. How do I make it work?
Kristoffer,
based on the link you provided …
… that should be sufficient.