First of all I am new to imacros,I am trying to remove an element from a page using imacro in a random site, for which i have tried to use the javascript which throws me an error of .remove() is not a function
. Following is the piece of code which i have been trying:
var macro = "";
macro +="SET !DATASOURCE mobidomains2.csv";
macro +="SET !DATASOURCE_COLUMNS 1";
macro ="SAVEAS TYPE=PNG FOLDER=* FILE={{!COL1}}";
window.content.document.getElementsByClassName("results-explained").remove();
var ret="";
ret=iimPlay(macro);
I have also tried it with using .removechild()
, so is there any way that I can delete a specific div using imacro with javascript? Thanking you in advance.
The remove() method removes an element (or node) from the document.
getElementsByClassName
returns a HTMLCollection
. You should iterate through the set and then call the remove
method on each element. Also note ChildNode.remove
method is not widely-supported.
var collection = window.content.document.getElementsByClassName("results-explained");
Array.prototype.forEach.call(collection, function(node) {
node.parentNode.removeChild(node);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With