我是靠谱客的博主 光亮雨,这篇文章主要介绍JQ 通过选择器查询指定元素的标签名,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/** * @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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部