页面js选择器,class 的选择器使用

mac2025-03-16  13

$('.menu').on('click', function () {                 var url = $(this).parent().find('.active').children('a').attr('data-id');                 var name = $(this).parent().find('.active').children('a')[0].text;                 var id = $(this).parent().find('.active').children('a')[0].hash;                 if (url != null) {                     top.learun.frameTab.open({ F_ModuleId: id, F_FullName: name, F_UrlAddress: url });                 }                 //console.log($(this).parent().find('.active').children('a')[0].hash)             })

 

 

首先获取当前页面中类是 menu 的标签,给它添加点击事件

然后再$(this)但前标签下的父节点寻找class中有active的标签find(遍历)然后选择到它的孩子节点的某个属性

最新回复(0)