开发者

How to check if a text field has wrapped and the number of lines it has wrapped to

开发者 https://www.devze.com 2023-01-16 08:20 出处:网络
I have a complex vertical nav which includes transparent PNG\'s in my design. I need to make these menus grow dynamically in h开发者_如何学Pythoneight because the content is pulled from a CMS and some

I have a complex vertical nav which includes transparent PNG's in my design. I need to make these menus grow dynamically in h开发者_如何学Pythoneight because the content is pulled from a CMS and some buttons can grow in height depending on how many lines the text field wraps to.

Here is my scernario:

<ul>
 <li>
     <a>
       <span>
            <span> This is an example of a very long menu name which will wrap<span>
         </span>
     </a>
 </li>
</ul>

I need to use some javascript to work out if the second span tag has wrapped the text inside it and by how many lines so that I can deliver a different background image for that menu item.

Does anyone know how I would go about this?

Thanks, James


Managed to find a solution. I can check the height of the span using jQuery's .height() method and if the height is anything bigger than the original size, I can deliver a different image for that button :)

0

精彩评论

暂无评论...
验证码 换一张
取 消