I have this jquery code below and I need it to attach events on controls as the controls are created dynamically.

Right now they are set for a specific control.

Thanks

$(document).on("click", "#day1Header", function () {
        $("#day1Details").slideToggle("normal");
        $(".expandDay1Details").html($(".expandDay1Details").html() == 'CLOSE' ? 'EDIT' : 'CLOSE');
    });

    $(document).on("click", "#day2Header", function () {
        $("#day2Details").slideToggle("normal");
        $(".expandDay2Details").html($(".expandDay2Details").html() == 'CLOSE' ? 'EDIT' : 'CLOSE');
    });

    $(document).on("click", "#day3Header", function () {
        $("#day3Details").slideToggle("normal");
        $(".expandDay3Details").html($(".expandDay3Details").html() == 'CLOSE' ? 'EDIT' : 'CLOSE');
    });

May I see an example of the HTML that this is code is used on? This will help me provide a good answer.

It would ve also more proper to state what legacy language you are dealing with.

@pyTony this is Javascript using the jQuery framework so not exactly legacy and probably not the best place for this.

--> MOVED to JavaScript forum from Legacy Languages (pyTony)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.