By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,369 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,369 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Expand|Select|Wrap|Line Numbers
  1.  <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">
  2.  
  3.  
  4.  
  5. Here is my javascript
  6.  
  7.  
  8.     function init(){
  9.         document.querySelectorAll("#buttonImage").onclick = changeFont;
  10.  
  11.  
  12.  
  13.     function changeFont(){
  14.         document.querySelectorAll("word").style.fontFamily = "'Oswald', sans-serif";    
  15.     }
  16.  
  17. }
Jan 19 '15 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
1) querySelectorAll() 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().
Jan 19 '15 #2

Post your reply

Sign in to post your reply or Sign up for a free account.