0

I am trying to write a searchbar and want to have a dynamic amount of params for the search Therefore I am trying to get jquery to firstly load the searchbar (in another file) and then clone it and append it to the body

I already tried changing serveral selectors but it doesnt work as expected

This is my jquery script

        $(document).ready(function(){
            $("#add").click(function(){
                $("#add_div").load("test.php");
            });
            $("#addbutton").click(function(){
                $("#add_div").clone().appendTo("body")
            });
        });

test.php contains the searchbar

The first load is running as expected (I get the searchbar once) but all clicks on the 'addbutton' (which is loaded with the searchbar) dont do anything

EDIT: fixed a small mistake

John
  • 1
  • 2

1 Answers1

0

the $("addbutton") selector must be wrong, it searches for the addbutton element which isn't a valid html element.

Hagai Wild
  • 1,307
  • 7
  • 17