hoilzz
hoilzz

Reputation: 105

jquery error, Uncaught TypeError: Cannot use 'in' operator to search for 'scrollLeft' in undefined

when ABC is loaded, How to remove this (in fadeout effect)

I tried

view.html

    <%if notice %>
      <span class = "notice"><%= flash[:notice] %> </span>
    <% end %>

<script>

<script>

$( "span.notice" ).ready(function() {
  $( this ).fadeOut( 1000, function() {
    $( this ).remove();
  });
});
</script>

I received error message that

Uncaught TypeError: undefined is not a function
jquery-1.10.2.js:6820 Uncaught TypeError: Cannot use 'in' operator to search for 'display' in undefine

How to I fix it?

Upvotes: 0

Views: 1597

Answers (2)

lalitpatadiya
lalitpatadiya

Reputation: 720

Try below code.

$( document ).ready(function() {
      $( 'span.notice').fadeOut( 1000, function() {
        $('span.notice').remove();
      });
});

You can not use ready on "span.notice".. so you need to use dom element and on dom ready you need to fadout and then remove your span. Please make sure you have added necessary jquery files in proper manner.

Upvotes: 0

Jeremy Thille
Jeremy Thille

Reputation: 26380

$( "span.notice" ).ready( ? I don't think so. The DOM can be ready, but you can't listen for a HTML element to be. Just remove this, and also the double <script> opening.

<script>
$( "span.notice" ).fadeOut( 1000, function() {
    $( this ).remove();
});
</script>

Upvotes: 1

Related Questions