jquery - Apply different images according to size for navigation menus -


I & lt; Li & gt; I want to use different background images as per the size. Element for navigation menu

I am trying to style the Wordpress menu with the dropdown box, but I have a lot of link names, which go into one line, but some lines have long since, and they are different .

For those & lt; Li & gt; Element, which goes on one line, I have implemented background image using simple CSS, but I want to check if something & lt; Li & gt; In my case, the element, which is higher than the height for a line, has a line height of 34px; If there are two rows, the height is already 54px, and the default background image does not suit there (it repeats itself) but I want to apply the bigger image to that 54 px box with jquery.

I came up with this code, which is definitely not working:

  var line_height = $ ("neo li"). Height (); If (line_height> 34) {$ (this). CSS ("background-image", url ("images / nav-two-lines.png")}}   

I tried to check that line_heet value, and this 34px Was there. I'm sure it only reads the first element, and is true, it has a line, and its height is 34px.

I hope, there will be someone who can help.

Thank you!

If the problem is that the image itself repeats itself, then you want to modify CSS to read :

  background: url (...) no-repeat;   

In response to your question, you need a loop through all of Lee's, do not just take one exam:

  $ ('nav li '). Each (function () (if ($ (this). ()> 34) $ (this). Css ('background-image', 'url (images / nav-two-line page)');});    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -