I need help aligning a series of text boxes with their corresponding labels. The challenge is that they are in separate divs, preventing the use of the inherit keyword. I attempted to align them using javascript/jquery code below, but $(tb).css('left')
only returns auto
. Is there a way to achieve this alignment without resorting to tables and utilizing html, css, and/or javascript/jquery?
$(function() {
$('#infoLabels label').each(function(idx,lbl) {
var tb = $('#' + lbl.htmlFor);
($(tb).width() > $(this).width()) ? $(this).width($(tb).width()) : $(tb).width($(this).width());
$(this).css('left',$(tb).css('left'));
});
});
http://jsfiddle.net/apandit/k5max5fw/1/
Any suggestions would be greatly appreciated.