javascript - Getting error "Cannot read property 'show' of null" in console when trying to sho

If you scroll to the end of this article you'll see this list of names:WowanaOomvyExzaGozerHen

If you scroll to the end of this article you'll see this list of names:

  • Wowana
  • Oomvy
  • Exza
  • Gozer
  • Hentra
  • Molisa
  • Gizic
  • Yaberi
  • Anea
  • Dymi
  • Gibbal

Each of these list items contain an image and the link. The image associated with each li is hidden with CSS. I have been trying to setup some jQuery to so that the image shows when the link is rolled over.

Here is the code:

<li><img class="previewImage" src=".png" width="200" height="151" /><a href="names/gibbal">Gibbal</a></li>

And the simple jQuery I apply in the console to test:

$('.previewImage').show();

And the error:

TypeError: Cannot read property 'show' of null

What am I overlooking? This is driving me crazy and imagine it's something very simple.

If you scroll to the end of this article you'll see this list of names:

  • Wowana
  • Oomvy
  • Exza
  • Gozer
  • Hentra
  • Molisa
  • Gizic
  • Yaberi
  • Anea
  • Dymi
  • Gibbal

Each of these list items contain an image and the link. The image associated with each li is hidden with CSS. I have been trying to setup some jQuery to so that the image shows when the link is rolled over.

Here is the code:

<li><img class="previewImage" src="http://www.brandroot./images/brands/gibbal.png" width="200" height="151" /><a href="names/gibbal">Gibbal</a></li>

And the simple jQuery I apply in the console to test:

$('.previewImage').show();

And the error:

TypeError: Cannot read property 'show' of null

What am I overlooking? This is driving me crazy and imagine it's something very simple.

Share Improve this question asked Jun 13, 2014 at 0:52 Michael RaderMichael Rader 5,9678 gold badges37 silver badges44 bronze badges 1
  • You have multiple libraries loaded. $ is not jQuery, it's some other library (mooTools, maybe?). – Barmar Commented Jun 13, 2014 at 0:56
Add a ment  | 

1 Answer 1

Reset to default 4

For some reason, doing

jQuery('.previewImage')

worked, whereas

$('.previewImage')

is null. This might be caused by another library using the $ shortcut (prototype perhaps?). Long story short: use the first Syntax instead of $

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744989452a4604811.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信