Title: how to put js in function.php
Last modified: August 30, 2016

---

# how to put js in function.php

 *  Resolved [taghaboy](https://wordpress.org/support/users/taghaboy/)
 * (@taghaboy)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/how-to-put-js-in-functionphp/)
 * Hello,
    I used this code in the footer of my theme, to insert to “Hello World”
   in the div id=”content”
 *     ```
       <script type="text/javascript">
       	document.getElementById('content').innerHTML = '<span class="copyright">Hello world</span>';
       </script>
       ```
   
 * So now, i’d like to put the code in the **function.php**
 * Please how to do that?
 * Thanks

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Digico Paris](https://wordpress.org/support/users/digico-paris/)
 * (@digico-paris)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/how-to-put-js-in-functionphp/#post-6682628)
 * Hi taghaboy,
 * What you ask is “possible”, but would require a lot of:
 * ”./’ changes
 * Which will most likely end in php errors or site wreckage. If you need to add
   JS, it’s way better to add it either in
 * header.php or footer.php theme file.
 * Plus, you’ll have examples in these files if it’s done well.
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [10 years, 7 months ago](https://wordpress.org/support/topic/how-to-put-js-in-functionphp/#post-6682642)
 * Maybe it’s easier if you use a plugin, [https://wordpress.org/plugins/custom-css-js-php/](https://wordpress.org/plugins/custom-css-js-php/)
 * Note that you’ll probably only want the JS bit (in the plugin) and not the HTML:
 *     ```
       document.getElementById('content').innerHTML = '<span class="copyright">Hello world</span>';
       ```
   
 *  Thread Starter [taghaboy](https://wordpress.org/support/users/taghaboy/)
 * (@taghaboy)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/how-to-put-js-in-functionphp/#post-6682687)
 * Thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘how to put js in function.php’ is closed to new replies.

## Tags

 * [function.php](https://wordpress.org/support/topic-tag/function-php/)
 * [js function](https://wordpress.org/support/topic-tag/js-function/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [taghaboy](https://wordpress.org/support/users/taghaboy/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/how-to-put-js-in-functionphp/#post-6682687)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
