liboqiao 2019-06-27
<ul> <Li>a</li> <li>b</li> </ul>
<div id="test"> <b>Hello</b> I'am a ninja </div> var a = document.getElementById('test').querySelectorAll('div b'); console.log(a);
(function() { var count = 1; this.rootedQuerySelectorAll = function(elem, query) { var oldId = elem.id; try { return elem.querySelectorAll('#' + elem.id + " " + query); } catch(e) { throw e; } finally { elem.id = oldId; } } }) () var b = rootedQuerySelectorAll( document.getElementById('test'), 'div b' ) console.log(b);