Listen to changes within a DIV and act accordingly

后端 未结 7 557
谎友^
谎友^ 2020-11-28 23:34

I have a function that grabs an XML document and transforms it according to an XSL document. It then places the result into a div with the id laneconfigdisplay

相关标签:
7条回答
  • 2020-11-29 00:34

    If possible you can change the div to an textarea and use .change().

    Another solution could be use a hidden textarea and update the textarea same time as you update the div. Then use .change() on the hidden textarea.

    You can also use http://www.jacklmoore.com/autosize/ to make the text area act more like a div.

    <style>
    .hidden{
    display:none
    }
    </style>
    
    <textarea class="hidden" rows="4" cols="50">
    
    </textarea>
    
    
    $("#hiddentextarea").change(function() {
    
    alert('Textarea changed');
    
    })
    

    Update: It seems like textarea has to be defocused after updated, for more info: How do I set up a listener in jQuery/javascript to monitor a if a value in the textbox has changed?

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