q5play
    Preparing search index...

    Function createEl

    • 📑 Creates a new HTML element and adds it to the page. createElement is an alias.

      Modify the element's CSS style to change its appearance.

      Use addEventListener to respond to events such as:

      • "click": when the element is clicked
      • "mouseover": when the mouse hovers over the element
      • "mouseout": when the mouse stops hovering over the element
      • "input": when a form element's value changes

      q5 adds some extra functionality to the elements it creates:

      • the position function makes it easy to place the element relative to the canvas
      • the size function sets the width and height of the element
      • alternatively, use the element's x, y, width, and height properties

      Parameters

      • tag: string

        tag name of the element

      • Optionalcontent: string

        content of the element

      Returns HTMLElement

      element

      await Canvas(200);

      let el = createEl('div', '*');
      el.position(50, 50);
      el.size(100, 100);
      el.style.fontSize = '136px';
      el.style.textAlign = 'center';
      el.style.backgroundColor = 'blue';
      el.style.color = 'white';