ux listen

Description

Listen on the element ID for the event name and then trigger the function given

Parameters

string

The event to listen

Type

mouseover

mouseout

changing

change

click

 

string

The element ID to watch

function

The function to trigger on the event

Return


No return value

Example


<span id="listen-example">Try to pass over me</span>
<script>
 ux.listen("mouseover","listen-example",function(){this.className='has-background-danger';});
 ux.listen("mouseout","listen-example",function(){this.className='';});
</script>

 

Preview:

In the preview of the example you can see the result of the string:

A function to trigger an event appears: "Try to pass over me". When you hover over the line, it is highlighted wit red until you keep the mouse over it.