Trying to add dynamic borders on my website top, left, and right sides… The pages on my site are dynamic… That is they change… I need to have a script that adapts a div to the webpage simply…
Anyone know this?
I got this script from some guy on this forum, but I am trying to avoid jQuery (don’t ask)…
<p class="bgr">Content content content</p>
<script type="text/javascript">
$('.bgr').each(function(i,el){
$('<div class="bgr_left"/>').height($(this).height()+'px').appendTo($(this));
// similar for top, right, and bottom
});
</script>
Calculating dimensions in a cross-browser fashion (as the height() you’re fetching and setting there) is an incredibly tedious task to do in plain JavaScript. That’s, among other reasons, why libraries such as jQuery were built in the first place.
I’d strongly advise you NOT to do it without any framework – if you don’t like jQuery, fine, but use another one.