How to call an image with javascript and send if off?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Blindver
    New Member
    • Jan 2015
    • 1

    #1

    How to call an image with javascript and send if off?

    I am trying to call an img in html and send if off but I can't seem to figure out where I am going wrong. I am sending it off to a <textarea>. (still new at java script)

    Here is my HTML
    Code:
     <div id="buttonWrapper"> <div id="button01"> <img id="buttonImage" src="http://bytes.com/imges/font01.png" alt="button01"> </div> <div id="textArea"> <div id="instruction"> <p> *Type a word here, and click diffrent styles and sizes</p> </div> <div id="textSpot" > <textarea name="word">
    
    
    
    Here is my javascript
    
    	
    	function init(){
    		document.querySelectorAll("#buttonImage").onclick = changeFont;
    	
    	
    	
    	function changeFont(){
    		document.querySelectorAll("word").style.fontFamily = "'Oswald', sans-serif";	
    	}
    	
    }
    Last edited by Rabbit; Jan 19 '15, 05:28 AM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    1) querySelectorAl l() returns a NodeList/HTMLCollection, not an HTMLElement (even if there is only one element in the match) on which the defined properties would make sense.

    2) "word" is an invalid HTML element.

    what you want is querySelector().

    Comment

    Working...