在Page load上触发的propertychange事件

时间:2021-03-01 20:35:54

I am using textarea and I have binded propertychange event to it. Below is the code I used

我正在使用textarea,我已将binded属性事件更改为它。以下是我使用的代码

$('#textareaID').bind('input propertychange', function() {});

But this event gets triggers only when changes happen to the textarea after the page loads. I want it to get triggered when page loads itself. Since on page load I am assigning a value where I want it to happen at that time. Is it possible to trigger at page load itself ?

但是,只有在页面加载后textarea发生更改时,此事件才会触发。我想让它在页面加载时被触发。因为在页面加载时,我正在分配一个我希望它在那时发生的值。是否可以在页面加载时触发?

1 个解决方案

#1


6  

Does triggering it manually work for you?

是否手动触发它?

Example in jsFiddle: http://jsfiddle.net/VAT83/

jsFiddle中的示例:http://jsfiddle.net/VAT83/

$(function() {
    var textValue = $('#textValue');        
    $('#textareaID')
         .bind('input propertychange', function() {
             textValue.html($(this).val());
         })
         .trigger('propertychange');
});​

#1


6  

Does triggering it manually work for you?

是否手动触发它?

Example in jsFiddle: http://jsfiddle.net/VAT83/

jsFiddle中的示例:http://jsfiddle.net/VAT83/

$(function() {
    var textValue = $('#textValue');        
    $('#textareaID')
         .bind('input propertychange', function() {
             textValue.html($(this).val());
         })
         .trigger('propertychange');
});​