/**
* @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 通过选择器查询指定元素的标签名的全部内容,更多相关JQ内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复