How to identify from where it got trigger

I have two trigger point one is edit icon and other is add save button . on click on edit iocn and save button one model get open . model is same for both .

I want to make back focus on click on (x) icon of model from where it got trigger . how should i identify from where it got trigger from edit iocn or from add save button . and how to back focus on them ?

1 answer

  • answered 2022-05-04 12:13 Mahri Ilmedova

    One way you could do this by passing a value into your function. Let me make it clear by following example.

    So there are two buttons

    <button onclick="myFunction('edit')">Edit</button>
    <button onclick="myFunction('save')">Save</button>

    and Javascript function will look something like this

        function myFunction(event_type){
            if(event_type == 'edit'){
                //your further code for edit event goes here
                //if event_type is not edit, then it's obviously save event
                //so your further code for save event goes here 

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum