Manipulate HTMLCollection with Javacsript



JS新手问题:

我试图操纵Wordpress插件的HTMLCollection,我失败了几个小时了。我想删除属性baseURI"或者将其设置为null

jQuery(document).ready(function( $ ){
//HTML Collection
var test = document.getElementsByClassName("post-2968"); 

//manipulate <a> object inside <div>
test[0].childNodes[0].target="_blank";
test[0].childNodes[0].href="www.google.com";

//manipulte property of div
test[0].baseURI = undefined; // also tried "" or null

console.log(test)
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

这是日志:Console.logg

如文档中所写:

baseURI——在只读<----属性返回节点的绝对基URL。>

所以我认为你不能改变它。

最新更新