Using a web server with Arduino
You can use an Arduino Yun: it has a 32u4 microcontroller coupled with a cpu running linux. The linux side already has a webserver: together with the Bridge library, you can use REST-like APIs to control a sketch, or build a web app that uses that APIs.

One example of remotely control an Arduino (although using an Android app instead of html+js) is this. Here is its source code.