Solution 1 :

I think you are looking for an event listener. Things like onblur, onclick, onmouseover, onmouseout, etc. are not attributes, but rather are inline event listeners that fire when that event occurs.

//select the myElement somehow, either using the element's ID, class, etc.
myElement.addEventListener('focusout', function() {
  updateItem(index, row);
  hideInputBoxOnElement(row);
});

You can have as many event listeners as you want in an element, so you can even do something like this:

//select the myElement somehow, either using the element's ID, class, etc.
myElement.addEventListener('focusout', function() {
  updateItem(index, row);
});

//select the myElement somehow, either using the element's ID, class, etc.
myElement.addEventListener('focusout', function() {
  hideInputBoxOnElement(row);
});

Just a suggestion, you might want to use the blur event instead of the focusout event. What’s the difference, you ask? In web browsers, what’s the difference between onblur and onfocusout?
Basically, focusout is triggered when the element itself or any of its children lose focus, whereas blur only fires for the element itself.

It is often said that javascript event listeners that don’t begin with the prefix on- is considered a better practice compared to starting with the prefix on-, but I personally don’t think it makes much of a difference.

Problem :

Hi can I set 2 attributes to same element ?
I want to run 2 functions when I outfocus on one item ? any idea if not any alternative ? thanks.

 listEl.setAttribute('onfocusout', `updateItem(${index}, ${row})`, 'onfocusout', `hideInputBoxOnElement(${row})`);

Comments

Comment posted by developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute

Set attribute only sets one attribute. You will need to use two calls (in this example it would only add 7 more characters)

Comment posted by evolutionxbox

Check the first example in the link I posted

Comment posted by evolutionxbox

Ahhh I see what the op was asking now. Good spot

Comment posted by evolutionxbox

I updated the element variable name to not confuse things, and the event name should be

By