Trigger javascript function onclick -


i created simple painting application, of script mudcu, sketch.js.

i made changes within code, have problems trigger function sets color of pencil.

var sketch = function(config) { "use strict"; var = this; ........... var ctx2 = layer2d[2]; // style object. this.zoom = 1;  this.style = {     tool: "brush",     globalalpha: 1,     globalcompositeoperation: "source-over",     strokestyle: "#000",     linewidth: 5,     linecap: "round",     linejoin: "round" 

my question how can set "this.style" strokestyle example "#d55151" when user clicks button?

using jquery solution problem:

<button id="mybtn">my button</button> 

jquery

$('#mybtn').click(function(){   // set style   that.style.strokestyle = "#d55151"; // var = this; }); 

update:

the pure javascript answer :

document.getelementbyid('mybtn').onclick=function(){    // set style   that.style.strokestyle = "#d55151"; // var = this; }; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -