最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - propertychange event to trigger on Page load - Stack Overflow

programmeradmin1浏览0评论

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

$('#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 ?

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

$('#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 ?

Share Improve this question edited Jul 6, 2012 at 4:28 Derek 朕會功夫 94.5k45 gold badges198 silver badges253 bronze badges asked Jul 6, 2012 at 4:23 LollyLolly 36.5k44 gold badges122 silver badges163 bronze badges 1
  • You have to wait at least until the DOM loads. – Derek 朕會功夫 Commented Jul 6, 2012 at 4:29
Add a ment  | 

1 Answer 1

Reset to default 8

Does triggering it manually work for you?

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

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

评论列表(0)

  1. 暂无评论