How can I access the parent node method in layui?

In Layui, you can use the parent() method from jQuery to access the parent node. Here is an example:

HTML code:

<div id="parent">
  <div id="child">子节点</div>
</div>

JavaScript code:

var parent = $('#child').parent();
console.log(parent.attr('id')); // 输出:parent

In the example above, using $(‘#child’).parent() allows you to access the parent node of the child element. You can then use the attr() method to retrieve the id attribute value of the parent node.

bannerAds