jQuery add dotted lines

Hi Guys,

I have few UL lists in a page.
Here is the code below including the jQuery. What i am trying to do is fill in the gap between the end of "href" text to the "span" with dotted line" suc has in the screenshot attached.

The HTML

<div id="poi">

    <ul>
       <li><a href="#">Lorem Ipsum is simply dummy  <span>&raquo;</span></a></li>
      <li><a href="#">Lorem Ipsum is  <span>&raquo;</span></a></li>
      <li><a href="#">Lorem Ipsum is simply <span>&raquo;</span></a></li>
    </ul>

    <ul>
       <li><a href="#">Lorem Ipsum is simply dummy  <span>&raquo;</span></a></li>
       <li><a href="#">Lorem Ipsum is  <span>&raquo;</span></a></li>
      <li><a href="#">Lorem Ipsum is simply <span>&raquo;</span></a></li>
    </ul>

</div>

Open in new window


$(document).ready(function() {
	var poiList = $("#poi ul");
	
	$(poiList).each(function() {
		var poiListWidth = ($(this).width());
		$(this).css({'width': poiListWidth+10 });	
	});	
});

Open in new window


dotted lines per distance between end of text to span
RefaelAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
I think this is about the closest you'll get because of kerning in the fonts:
http://jsbin.com/okUGEHe/2/edit

I moved your span outside the <a> to make this easier

html:
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="poi">
  
    <ul>
       <li><a href="#">Lorem Ipsum is simply dummy</a><span>&raquo;</span></li>
      <li><a href="#">Lorem Ipsum is</a><span>&raquo;</span></li>
      <li><a href="#">Lorem Ipsum is simply</a><span>&raquo;</span></li>
    </ul>

    <ul>
       <li><a href="#">Lorem Ipsum is simply dummy</a><span>&raquo;</span></li>
      <li><a href="#">Lorem Ipsum is</a><span>&raquo;</span></li>
      <li><a href="#">Lorem Ipsum is simply</a><span>&raquo;</span></li>
    </ul>

</div>
</body>
</html>

Open in new window


$(document).ready(function() {
  var poiList = $("#poi ul li a");
  
  $(poiList).each(function() {
    var poiListWidth = $(this).parent().width();
    console.log($(this).width());
    while ($(this).width() < (poiListWidth-200)) {
      $(this).text($(this).text() + ".");
    }
  });	
});

Open in new window


result:
result
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RefaelAuthor Commented:
Hi tagit
Thank you. I managed to do the same using simply CSS and it works just as good as your jQuery solution. Thank you now i know how to when i need to use jQuery :-)
0
RobOwner (Aidellio)Commented:
Please post your solution too as it would be a good resource to have
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.