/**
* @param {*} selector 选择器
* @param {*} targetEle 查询目标标签名
* @returns 如果匹配返回true,如果不匹配返回该标签名
*/
function checkEle(selector, targetEle) {
let html = $(selector).html();
let thisEle = html.substring(html.indexOf('<')+1, html.indexOf(' '));
if(thisEle == targetEle) {
return true;
}else {
return thisEle;
}
}
// 调用方法
console.log(checkEle('#myForm', 'form'));
JQ 通过选择器查询指定元素的标签名
最新推荐文章于 2024-09-05 15:53:15 发布