rewrite with plain JavaScript (no jQuery)