In your code example, you were binding a click event handler to $('details_img'), which means you were binding it to a custom element, e.g., as if your HTML contained <details_img></details_img>. I assume that details_img is actually a class name or and id.
In your code example, you were also calling postImgCar() after attaching a click event handler to details_img, presumably when the page loads. If that isn't what you meant to do, then of course take out that extra call.
If you want postImgCar() to execute each time the user clicks details_img, and after the href attribute is set, do this, if details_img is a class name:
$('.details_img').click(function(i){
// ...
$(this).closest(".page").find(".car_detail").parent().attr('href', $(this).attr('src'));
posImgCar();
// ...
});
Or this, if details_img is an id:
$('#details_img').click(function(i){
// ...
$(this).closest(".page").find(".car_detail").parent().attr('href', $(this).attr('src'));
posImgCar();
// ...
});
Finally, if you are using jQuery 1.6 or later, consider using the .prop() method, instead of .attr(). See the jQuery API documentation for .prop() for an explanation.