Home>

for some reason the parameters that I want to transmit Create another button by pressing, which must have the text of the same button, but another class

<
Script Type= "Text /JavaScript" >
    $ ('. AddSpell'). ON ('Click', Function () {
        $ ('. Placemyspells'). Append (' <
Button />
', {text: "add spell", class:' myspell '});
    });
≪
/script >

Here the button is created, but she does not have text (

  • Answer # 1

    JQuery .APPend () documentationHe tells us that this method takes on the quality of the arguments only the function that returns the following el-you, or the El-You yourself:

    Dom Element, Text Node, Array of Elements and Text Nodes, HTML String, OR JQuery Object

    The easiest solution to your problem -HTML STRING:

    $ ('. Placemyspells'). Append (' <
    Button Class= "Myspell" >
    Add spell <
    /Button >
    ');
    

    Well, or .append ($ ('

    @ De.minov therefore wrote -the easiest option. The question is showing that even append -it is difficult, and here it is still addclass and text

    InDevX2021-05-27 04:07:40