Example There is a yellow block, it needs to assign a width the same as the menu tab. What is the correct way to do this? The blocks are in different containers and different phtml files. The width of the menu tab is dancing because the end user does not always have the same font.

  • $('#block-acceptor').width( $('#block-donor').width() ) - br3t
  • Override the layout?) - Qwertiy

1 answer 1

Change selectors on their own. Here, width () = element length + padings

 $(document).ready(function() { $('#menu-item').width($('#yellow-block').width()); }); 
  • Thank you It will be correct if I hardly write a few lines $ ('# menu-item'). Width ($ ('# yellow-block'). Width ()) ;, only with my own classes? Since you need to bind to each tab block. - Sylon
  • Of course. Only you had better not bind according to the class, namely by the ID. Classes can be many on the page, and the ID of the element should be unique. - Kernel Panic