2013-04-14 8 views
2

어떤 이유로 든 호출중인 모든 함수가 작동하지 않습니다. "fadeOut", "fadeIn"또는 "fadeTo"중 하나입니다. 오류가 발생합니다.Object # <HTMLHeadingElement>에는 'fadeOut'메서드가 없습니다.

다음은 HTML뿐만 아니라 js 스크립트 코드입니다.

<html> 
    <head>  
     <script type='text/javascript' src="js/jquery-1.9.1.min.js"></script> 
     <script type="text/javascript" src="js/script.js"></script> 
     <link rel="stylesheet" type="text/css" href="stylesheet.css"> 
    </head> 
    <body> 
     <h1>Hello world</h1> 

     <ol> 
      <li> Hello</li> 
      <li> My </li> 
      <li> Name </li> 
      <li> is </li> 
     </ol> 

    </body> 
</html> 


$(document).ready(function(){ 

    $('ol li').click(function(){ 
     this.fadeOut('slow'); 
    }); 

    $('h1').click(function(){ 
     this.fadeOut('slow',0.5); 
    }); 

    $('li:nth-child(1)').mouseenter(function(){ 
     ('li:nth-child(2)').fadeOut('slow',0.25); 
    }); 

}); 

누군가 내가 잘못하고있는 것을 설명해 줄 수 있습니까?

+0

'$ ('리 : n 번째 자녀 (2)') '. ? – ted

답변

6

당신의 jQuery 것없는 개체의 jQuery 메소드를 호출하려는 감사드립니다. 그래서 this 등, $(this)된다

$(document).ready(function() 
{ 
    $('ol li').click(function() 
    { 
     $(this).fadeOut('slow'); 
    }); 

    $('h1').click(function() 
    { 
     $(this).fadeOut('slow',0.5); 
    }); 

    $('li:nth-child(1)').mouseenter(function() 
    { 
     $('li:nth-child(2)').fadeOut('slow',0.25); 
    }); 
}); 
+1

아 $ 기호를 잊어 버렸습니다. 지금 바보처럼 느껴져 ... Thx! – mokko211

관련 문제