'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 ?



Solution 1:[1]

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

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mahri Ilmedova