I have an Image object as following:
var img_BlinkingGreen = new Image();
img_BlinkingGreen.src = "Images/UIFiles/transparent-area.gif";
I want to set attributes of image object and a class and a click event. How can I do that?
I am doing like this but it is giving me an error
img_BlinkingGray.attr({
position: "absolute",
opacity: ".1",
height: height,
width: width,
left: left,
top: top,
class: lnk_question
}).onclick("GoToStep('" + nextAns + "');");
How can I do this?
No-one has posted the right answer.
.css()to set styles,.attr()to set attributes.click+.attr("data-nextAns")(or.data(), if your jQuery version supports it).Code: