Score:0

cant wrap element created twig

xk flag

I made a custom menu and I want to wrap an element with parent element through a script. element create from block-menu.html.twig Element: <li class="menu-item menu-item-level-1">

my js file:

var $ = jQuery.noConflict();
$(document).ready(function(){
  $( ".menu-item-level-1" ).wrap( "<div class='new'></div>" );
});

The console does not display any errors, the script is connected. Checked with an error. Why is the element not wrapping?

unusedspoon avatar
aq flag
Having a div as a child on a UL is invalid HTML that might be your problem
nihdrupal avatar
xk flag
no, my problem is that the script runs before this element is created for some reason. I created a parent through the console, but I couldn’t through JS
unusedspoon avatar
aq flag
change to (window).load then if you think that's the case. But i'd still not recommend adding the div into a ul like that
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.