Create an Area Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Area


You can create an <area> element by using the document.createElement() method:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<img src="" width="100" height="100" usemap="#planetmap">

<map id="myMap" name="planetmap">
</map>/*ww w .j av a  2s .  c om*/

<button onclick="myFunction()">create an AREA element with a link to ""</button>

<p id="demo"></p>

function myFunction() {
    var x = document.createElement("AREA");
    x.setAttribute("href", "");
    x.setAttribute("shape", "circle");
    x.setAttribute("coords", "120,50,10");

    document.getElementById("demo").innerHTML = "The AREA element was created.";


Related Tutorials