I am curious if pure javascript can replace this jQuery selector for IE7 and greater..
Do people simply change the markup and select using a class or is their away of selecting this using pure javascript
<h1 rel="xxxexternalxxx">Attribute Contains</h1>
var arrinput = $('[rel*="external"])
Any help would be much appreciated, thank you in advance
You can use getElementsByAttribute , then loop and filter:
var rels = getElementsByAttribute('rel');
var attr = 'external';
var result = [];
for (var i=0; i<rels.length; i++) {
if (rels[i].getAttribute('rel').indexOf(attr) > -1) {
result.push(rels[i]);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.