问题描述
解决方案
You can get all the elements with the tag a by
document.getElementsByTagName("a")
It returns a HTMLCollection of all elements with the tag a.
Now we can loop over it and check if there is an element which has a title starts with 'FR'
using Strings startsWith()
method.
let allA = document.getElementsByTagName("a");
let found = false;
for(let l = 0; l < allA.length; l++){
if (allA[l].title.startsWith('FR')) {
found = true
}
}
console.log(found);
<a href="project/150" title="FR - This is an example" target="_blank">FR - This is an example"</a>
推荐阅读
- javascript - 使用扩展运算符在对象中添加键值对
- facebook - Facebook Like-Share iframe 最近是否崩溃了?
- python - 如何检索用户在 tkinter python 中选择的文件?
- android - 视图与其他视图重叠,因为它是最后绘制的 android
- node.js - Heroku PostgreSQL - 无法发送 SSL 协商数据包:资源暂时不可用
- javascript - 根据 id 合并两个数组
- swift - 如何从 Firebase 检索颜色值
- javascript - 将 HTML 脚本与 Blob 一起使用
- security - 读取 ACL 不会阻止对目录引用变量的访问
- java - 这是一个 JSP DB 链接问题。如果在 jsp 中检查输入,则 db 不会更新