JSFiddle - React, Tailwind, and code Playground

by Kishore Sahasranaman

HTML

<input type="text" class="dp1"></input>
<input type="text" class="dp2"></input>
<input type="text" class="rooms"></input>
<input type="text" class="persons"></input>
<input type="text" class="persons"></input>

JavaScript

function my_custom_function(selector, event) {
    $(selector).on(event, function (e) {
        var dateValue = $($(this)[0]).val();
        $.each($(selector), function (index, item) {
            $(item).val(dateValue);
            console.log(item);
        });
    });
}

my_custom_function(".dp1", "change")

my_custom_function(".dp2", "change")

my_custom_function(".rooms", "keyup")

my_custom_function(".persons", "keyup")