Question

So...I'm trying to make a pretty basic userscript. What I'm trying to do is just cloning this :

http://grab.by/o6Te

and putting it before this:

http://grab.by/o6Us

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

Was it helpful?

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top