Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2012
    Posts
    60
    Thanks
    65
    Thanked 0 Times in 0 Posts

    add onchnage event to a object

    Using jquery, is it possible to add a change event to an object that is in the javascript



    Code:
        var x = {
        
             a:1,
             b:2,
             c:3,
             d:4
        }
    
    
    
    x.c = 'new';
    
    
    x.change(function(){
    
    alert(this.c) //alerts 'new'
    
    
    }):

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,215
    Thanks
    12
    Thanked 338 Times in 334 Posts
    that’s not possible with the change event (which is for form elements only).

    however, such a feature is proposed for ES6 called Observe.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • Users who have thanked Dormilich for this post:

    code-in-time (05-16-2013)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •