jquery - How can I modify with css an image appended with javascript? -


i have appended image javascript using function looked this:

function show_image(src) {   var img = document.createelement("img");   img.src = src;   document.body.appendchild(img); } 

now when try modify style in css:

    img{      //style attributes etc. } 

the picture not react. how can fix this?

changing css in javascript solution:

add css in function:

    function show_image(src) {       var img = document.createelement("img");       img.src = src;       document.body.appendchild(img);       $(document).find(img).css(here add styles);     } 

example : $(your element).css("color", "red");

reference


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -