Is it possible put parameter in html form another javascript?

NodeBB Plugins
  • GNU/Linux

    I exaplain bettere. I have one controller, a page html and another file javascript.
    The controller pass the parameters to html page:

    	res.render('-------', data);

    In the html page I get parameters in this way:
    <div id="fish">

    Now suppose to have a javascript that when I click on a button do this:
    var div=$('#fish');
    var label=$('<label>');
    //In this label that I attacck to html page I want to have the other parameter that I //passed from the controller. I think I don't write a correct code here:

    Bu the code doesn't work. I can read like value. My question is it possibile something like this or I can' because html is execute firt respect javascript or something? Anyone can help me?


  • Community Rep

    in the client, those values are stored in

    For your jQuery, you don't append a closing tag, it does that automatically. When you want to insert the element into the div, you need to use appendTo(). Also, unless your label has additional data, I recommend using html() instead of text().

    Here's a fiddle. I also added an ID to the new label so it isn't added more than once.

Suggested Topics

| | | |