document.observe('dom:loaded', function() {

后端 未结 2 492
孤城傲影
孤城傲影 2021-02-10 04:05

Is there a way to have this prototype js trigger only when dom is changed and not loaded?

相关标签:
2条回答
  • 2021-02-10 04:56

    you can observe elements changing like this

    $('element').observe('change',function(e){ } );
    

    This is reserved for form elements though - textarea, select and input.

    The final code would look something like:

    document.observe('dom:loaded', function() {
        $('element').observe('change',function(e){
        // do something here
        });
    });
    
    0 讨论(0)
  • 2021-02-10 05:04

    The 'change' method is defined only for 'input', 'textarea' and select elements, not for general elements.

    The "dom:loaded" event is a user-defined event (as far as the browser is concerned) defined by the Prototype library. I don't believe that it is usable as any kind of template for a dom:changed event.

    What you are looking for are DOM mutation events, such as DomSubtreeModified (see 1). But I don't believe these are widely supported in browsers yet.

    0 讨论(0)
提交回复
热议问题