Hi All,
I'm trying to assign a margin-left to the next element's parent (line #10), but for some reason, it's not working.
Here's the relevant code:
- var $chars = $el.children('span').addClass('sl-w1'),
- $chars.each(function(i) {
- var $char = $(this);
- $char.wrap( $('<span/>').addClass('sl-wrapper') ) // wrap each of the words chars and set width of each wrapper = chars width
- .parent().css({'width' : '$char.width()' + 'px'});
- var initwd = $char.width();
- var newmar = 120 - initwd;
- $char.parent().css({'width': '120px !important'}); // Works
- $char.next().parent().css({'margin-left': -newmar + 'px !important'}); // DOESN'T WORK Adjust left margin of next .sl-wrapper
- });
Here's some typical html:
- <span class="sl-wrapper" ...>
- <span class="char1 sl-w1" ...>
- <span class="char1 sl-w2" ...>
- </span>
- more similar sl-wrappers ...
So what am I doing wrong?
Thanks, Bill