Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So lets assume you have an Elemen, you want to concat text to, and one which triggers a function when clicked on it. Then a propertie of an Object should be concatenated to the Element.</p> <p>Given this HTML</p> <pre><code> &lt;div id="myDiv"&gt;Hello&lt;/div&gt; &lt;div id="clickMe"&gt;Click Me&lt;/div&gt; </code></pre> <p>and following Example</p> <pre><code>var myObject = { propToConcat:"Hi" //This is the property you want to be concatenated }; var clickElement = document.getElementById("clickMe"); //This is your Element, the Click event is added to var concatElement = document.getElementById("myDiv"); //This is the Element where you display the Text; clickElement.addEventListener("click",concat); //THis adds the EventListener *You use Jquerys '.click' method for this* function concat () { concatElement.innerHTML += " " + myObject.propToConcat; //This is what you looking for. } </code></pre> <p>So the line <code>concatElement.innerHTML += " " + myObject.propToConcat;</code> Accesses the <code>innerHTML</code> property of you DOM Element, and appends a space and your Objects propertie.</p> <p>Then this is how the Output looks before</p> <p><img src="https://i.stack.imgur.com/xEUjh.png" alt="enter image description here"></p> <p>And after </p> <p><img src="https://i.stack.imgur.com/xkuDK.png" alt="enter image description here"></p> <p>I hope you understand the Example, as i didn't get the Context you are using your code with.</p> <p>Heres a <a href="http://jsbin.com/equvuv/1/edit" rel="nofollow noreferrer">JSBin</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload