# king-addons/51.1.74/includes/features/Custom_CSS/preview-handler.js

King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder, version 51.1.74. 39 lines.

- Page: https://pluginprobe.com/plugins/king-addons/51.1.74/code/includes/features/Custom_CSS/preview-handler.js
- Raw: https://pluginprobe.com/plugins/king-addons/51.1.74/raw/includes/features/Custom_CSS/preview-handler.js
- Modified: 2026-07-09T16:00:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/king-addons/51.1.74/code/includes/features/Custom_CSS/preview-handler.js#L10-L20`.

```javascript
"use strict";
(function ($) {
    $(window).on('elementor/frontend/init', function () {
        let KngCustomCSSHandler = elementorModules.frontend.handlers.Base.extend({
            onInit: function onInit() {
                if (this.$element.hasClass('kng-custom-css-yes')) {
                    this.applyKngCustomCSS();
                }
            },
            getReadySettings: function getReadySettings() {
                let settings = {
                    kng_custom_css: this.getElementSettings('kng_custom_css')
                };
                return $.extend({}, settings);
            },
            onElementChange: function onElementChange() {
                if (this.$element.hasClass('kng-custom-css-yes')) {
                    this.applyKngCustomCSS();
                } else {
                    let element_ID = this.$element.data('id');
                    $('.kng-custom-css-' + element_ID).remove();
                }
            },
            applyKngCustomCSS: function applyKngCustomCSS() {
                let options = this.getReadySettings();
                let element_ID = this.$element.data('id');
                $('.kng-custom-css-' + element_ID).remove();
                this.$element.before('<style class="kng-custom-css-' + element_ID + '">' + options.kng_custom_css.replace("[current-element]", '.elementor-element-' + element_ID) + '</style>');
            }
        });

        elementorFrontend.hooks.addAction('frontend/element_ready/global', function ($scope) {
            elementorFrontend.elementsHandler.addHandler(KngCustomCSSHandler, {
                $element: $scope
            });
        });

    });
})(jQuery);
```
