event.namespaceS2C Home « Objects « event.namespace

Event specified namespace property.

Description

The event.namespace Event object property, contains the value of the namespace specified on event triggering.

Syntax


Signature Description
event.namespaceThe value of the namespace specified on event triggering.

Parameters

None.

Return

A String object.

event.namespace Examplego to top of page Top

Contains the value of the namespace specified on event triggering.

In the example below when you enter or leave the 'div2' element the mouseenter and mouseleave JavaScript events fire but the namespace isn't passed across in the event so is undefined.

When we press the left button we trigger the mouseenter JavaScript event manually and the event.namespace parameter gets passed in the object and is output as part of the message.



$(function(){
  $('#div2').on({
     'mouseenter.ns1': function(event) {
       $(this).css({backgroundColor: 'orange', color: 'black'})
              .append('**entering "div2. " Namespace: ' + event.namespace);
     },
     'mouseleave.ns2': function(event) {
       $(this).css({backgroundColor: 'green', color: 'white'})
              .append('**leaving "div2. " Namespace: ' + event.namespace);
     }
  });
  $('#btn5').on('click', function(){
     $('#div2').trigger('mouseenter.ns1');
  });
});

div2. Some initial text.



Press the button below to action the above code:

go to home page Homepage go to top of page Top