You are using a jQuery function on a javascript DOM element. That cannot work. try changing this :
var verschuiven2 = document.getElementsByName('arch').clone();
To this :
var verschuiven2 = $('[name=arch]').clone();
Question
So...I'm trying to make a pretty basic userscript. What I'm trying to do is just cloning this :
and putting it before this:
What I have is:
function Addbutton() {
var verschuiven2 = document.getElementsByName('arch').clone();
$("#report_list tr:first").before("<tr><th colspan='2'>"+ verschuiven2 +"</th></tr>");
}
Edit: forgot to mention my error. It doesn't do anything. I tried the $('[name=arch]').clone(); , but it still doesn't do anything.
I found a solution:
function Addbutton() {
var selecteren2 = '<input name="all" type="checkbox" class="selectAll" id="select_all" onclick="selectAll(this.form, this.checked)"/>';
var verschuiven2 = '<input type="submit" name="arch" value="Verschuiven">';
$("#report_list tr:first").before("<tr><th colspan='2'>" + selecteren2 + verschuiven2 + "</th></tr>");
} Addbutton();
I think it's coded a bit weird but the Clone() function obviously didn't do what I thought it should do =/ Thanks guys
Solution
You are using a jQuery function on a javascript DOM element. That cannot work. try changing this :
var verschuiven2 = document.getElementsByName('arch').clone();
To this :
var verschuiven2 = $('[name=arch]').clone();