Hi Allex,

It looks like it was a white-space issue with the numbers in the divs. I have a test case working here:

http://salingermultimedia.com/jQuery/graph/

-Marshall


Smith, Allex wrote:
Marshall,

Thanks for your reply.
My css is set up like this:

.graph .bar { display: block;
        position: relative;
background: #B1D632; text-align: center; color: #333; height: 2em; line-height: 2em;

}

The original sample I got this from work perfectly when rendered without
using js.
http://applestooranges.com/goodies/css-for-bar-graphs/

Using any other block element results in the same missing style
attribute.

It's very odd, doing something like this:
var example = '<p class="bar"
style="width:'temp'%"><span>'temp'%</span></p>';
jQuery(this).html(example);

Still gives me an empty style attribute.

Allex

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Marshall Salinger
Sent: Tuesday, April 03, 2007 1:10 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: Am I missing something?



Untested, but I am fairly certain that you need to either use a block level element such as a paragraph tag or try setting strong to display:block.

-Marshall


AllexS wrote:
<!-- Before bargraph plugin is applied -->
<div class="graph">
     22
</div>
<div class="graph">
     89
</div>

<!-- Fairly basic function -->
jQuery.fn.bargraph = function() {
     return this.each(function(){
          var temp = $(this).text();
          var span = '<span>' + temp + '%' + '</span>';
          var bar = '<strong class="bar"></strong>';
          $(this).html(span);
          $(this).find('span').wrap(bar);
          $(this).find('strong').width(temp+'%');
     });
};

<!-- What I end up with -->
<div class="graph">
     <strong class="bar" style="">
          <span> 22 %</span>
     </strong>
</div>
<div class="graph">
     <strong class="bar" style="">
          <span> 89 %</span>
     </strong>
</div>

Why is width never applied?
I've tried stringing it together as well with the same result. Any ideas?





Reply via email to