title: Call function in JS file from Node.js
body: <p>What I am trying to do is when index.html sends a message back to the server, I want to call a function in <code>app.js</code> called <code>changeButton()</code> that will update a header color on index.html.</p>
  
  <p>Here is my node.js file:</p>
  
  <pre><code>var app = require('express')();
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  var express=require('express');
  
  var tools = require('./assets/js/app.js');
  app.use(express.static(__dirname + '/assets'));
  
  app.get('/', function(req, res){
    res.sendFile(__dirname + '/index.html');
  });
  
  io.on('connection', function(socket){
      socket.on('chat message', function(msg){
        console.log('message: ' + msg);
        if(msg == "color") {
          socket.emit("changeButton"); //working now
        }
      });
  });
  
  http.listen(3000, function(){
    console.log('listening on localhost:3000');
  });
  </code></pre>
  
  <p>app.js is in assets/js folder.</p>
  
  <pre><code>function getMessage() {
      $('form').unbind('submit').bind('submit', function(){
        socket.emit('chat message', $('#m').val());
        $('#m').val('');
          return false;
      });
  }
  
  function changeButton() {
    $('#status').css("background-color", "red");
  }
  </code></pre>
  
  <p>Here is index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;!-- app.js --&gt;
      &lt;script src="js/app.js"&gt;&lt;/script&gt;
      &lt;!-- app.css --&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/app.css"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1 id="status"&gt; Node Test &lt;/h1&gt;
  
      &lt;ul id="messages"&gt;&lt;/ul&gt;
          &lt;form action=""&gt;
              &lt;input id="m" autocomplete="off" /&gt;&lt;button onclick="getMessage();"&gt;Send&lt;/button&gt;
          &lt;/form&gt;
  
      &lt;script&gt;
          var socket = io();
          socket.on("changeButton", changeButton);
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>WORKING NOW!<br>
  THANKS!!!</p>