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

javascript - TypeError: document.observe is not a function - Stack Overflow

programmeradmin0浏览0评论

in my js file i wrote like this

 document.observe("dom:loaded", function() {
        add();
    });

but it show error TypeError: document.observe is not a function

I am using rails 3 & jquery-ui-1.10.0

can any one tell me why i am getting like this ?

Thanks in advance

in my js file i wrote like this

 document.observe("dom:loaded", function() {
        add();
    });

but it show error TypeError: document.observe is not a function

I am using rails 3 & jquery-ui-1.10.0

can any one tell me why i am getting like this ?

Thanks in advance

Share Improve this question asked Sep 23, 2014 at 10:33 Siva KBSiva KB 3571 gold badge6 silver badges19 bronze badges 2
  • Possible copy of stackoverflow./questions/1907702/… – Nitin Commented Sep 23, 2014 at 10:36
  • it also show the same error TypeError: $(...).observe is not a function – Siva KB Commented Sep 23, 2014 at 10:46
Add a ment  | 

1 Answer 1

Reset to default 5

As rails 3 uses jquery and you are writting code in prototype. That might creating issue here.

So try convert your code in jquery. Your code might look like.

$( document ).ready(function() {
// Run code
});

But consider below and make your changes as per your need

$(window).load(function(){
  // Run code ##It will run the js after the whole page is loaded.
});

$(document).ready(function(){
 // Run code ##It will run the js just after the loading of DOM. 
}); 
发布评论

评论列表(0)

  1. 暂无评论