admin管理员组文章数量:1410712
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 notjQuery
, it's some other library (mooTools, maybe?). – Barmar Commented Jun 13, 2014 at 0:56
1 Answer
Reset to default 4For 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 $
本文标签:
版权声明:本文标题:javascript - Getting error "Cannot read property 'show' of null" in console when trying to sho 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744989452a2636292.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论