It would be a little more obvious how to help if you included your HTML. I will assume that the object with class="sample"
is a parent object.
$(".test").hover(function() {
$(this).closest(".sample").wrap('<div style="border: 1px solid red;" />');
});
You will, of course need to unwrap this when you stop hovering or put in code not to wrap it over and over again.
It would be better if you used an existing object for the border and just change the class or style on hover, unhover. Since I don't know what your HTML is, I can only guess what might be used:
$(".test").hover(function() {
$(this).addClass("active");
}, function() {
$(this).removeClass("active");
});
And, then have a CSS rule:
.active {border: 1px solid red;}