Theoretically speaking, if I had a list of unordered items
<ul>
<li><a>Link1</a></li>
<li><a>Link1</a></li>
</ul>
How I could do the following with jQuery?
1) Find the width of each individual a
element
2) Find the width of each individual li
element
3) Subtract the width of each child a
element from the width of it's parent li
element
4) Then add the total to each parent li
element
This doesn't work:
$('ul > li').each(function() {
var liWidth = (this).width();
var aWidth = ('ul > li > a').width();
var subractedWidth = parseFloat(liWidth) - parseFloat(aWidth);
var newWidth = subtractedWidth + parseFloat(liWidth);
$(this).css('width',newWidth);
});
Thanks in advance!