Updates the identicon in a specified element.

jdenticon.update(element|selector[, hash|value[, padding]])
Browser: Yes Node.js: No


The following example show how to use the update method to render an icon on demand without using the data-jdenticon-value or data-jdenticon-hash attribute.

Update icon

<canvas id="identicon" width="100" height="100">

<script src="https://cdn.jsdelivr.net/npm/jdenticon@2.1.0"></script>
    jdenticon.update("#identicon", "ff8adece0631821959f443c9d956fc39");


element|selector can be either a canvas element, an SVG element or a CSS selector to a <canvas> or <svg> element. If the selector evaluates to multiple elements, all elements are updated.

If the second parameter hash|value contains a hexadecimal string of at least 11 characters it is considered a valid hash and used as base for the icon. If it contains any other value it is hashed using SHA1. If null or undefined is specified, or if the parameter is omitted, the function will in first hand look for a data-jdenticon-hash attribute on the element, in second hand for a data-jdenticon-value attribute.

padding specifies the padding surrounding the icon in percents in the range 0.0 to 0.5. Default is 0.08.