Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:07:37+00:00 2026-06-04T07:07:37+00:00

I am trying to monitor changes to select box (or nested option elements) with

  • 0

I am trying to monitor changes to select box (or nested option elements) with new Mutation Observer functionality. However, only “setAttribute” is triggering mutation observer’s callback for me.

Here’s the code I am using:

~function(doc, $) {
    var select = $('select');

    // http://www.w3.org/TR/dom/#mutation-observers
    var observer = new WebKitMutationObserver(function(mutations) {
        alert(mutations.length + " mutations happened");
    });

    observer.observe(select, {
        // monitor descendant elements – changing `selected` attr on options
        subtree: true,
        attributes: true
    });

    // this triggers Observer's reaction, but doesn't update select box UI
    select.setAttribute('value', 'whee'); 
    // this updates select box UI, but doesn't trigger mutation observer's callback
    select.value = "whee";
    // this also updates the UI, but doesn't trigger mutation observer's callback
    select.getElementsByTagName('option')[0].selected = true;
    //
    // neither does manual selecting of options trigger mutation observer unfortunately :(

    button.addEventListener('click', function(e) {
        e.preventDefault();
        // my goal is to react to this change here 
        select.value = Math.random() > .5 ? "whee" : "whoa";
    }, false);

}(document, function(selector) { return document.querySelector(selector); });​

And here’s this code in action http://jsfiddle.net/gryzzly/wqHn5/

I would like to react to changes to attributes (selected on <option> or value on <select>), any suggestion on why observer doesn’t react is more than welcome!

I am testing this in Chrome 18.0.1025.168 on Mac OS X. Production code would of course also have a moz prefix for the constructor and unprefixed version too, this is testing code.

UPD.

Tested the code in Firefox Nightly too and it behaves the same way as in Chrome, as well as in Chrome Canary. I have filled the bug for both browsers:

  • https://bugzilla.mozilla.org/show_bug.cgi?id=757077
  • https://code.google.com/p/chromium/issues/detail?id=128991

Please comment and vote for these bugs if you also find this problem annoying.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:07:38+00:00Added an answer on June 4, 2026 at 7:07 am

    @gryzzly, I’ve updated the Chromium bug with a detailed response: http://code.google.com/p/chromium/issues/detail?id=128991#c4

    Mutation Observers are limited to observing the DOM serialized state.
    If you’d like to know if Mutation Observers can observe something,
    just do take a look at what innerHTML outputs for the element. If you
    can see the change in state reflected in changes to the markup which
    that produces, then Mutation Observers should be able to hear about
    it.

    TL;DR: this is working as intended; to observe changes to IDL attributes like HTMLSelectElement.value, input events like onclick or onchange are probably your best bet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Python Watchdog to monitor a directory for changes. However,
I'm trying to coinfigure iwatch to monitor a directory for changes to some files.
Is this simple? I'm actually trying to monitor if an object changes (to determine
I'm trying to create a trigger that monitor changes on a table and then
I'm trying to monitor a process for memory changes with a timer. So I
I'm trying to use RegNotifyChangeKeyValue to monitor changes of a 64-bit registry key. To
I'm trying to monitor the performance information for openoffice using the performance counter class
I'm trying to monitor the gc activity in my app, using -verbosegc flag. I
I am trying to monitor URL's which are in my database. I an using
I'm trying to find a Git Commit Monitor for Windows. Does anyone know whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.