html:
<section class="one">
<div id="wrap">
<img src="./images/moon.png" alt="moon" style="width:200px;height:200px" Class="moon">
</div>
</section>
css:
html, body {
margin: 0;
padding: 0;
height: 100%;
}
section {
position: relative;
overflow: visible;
padding: 0px;
width: 100%;
height: 100%;
}
h1 {
text-align: Center;
font: 15px impact, sans-serif;
color: white;
font-size: 350%
}
#wrap {
width: 900px;
margin: 0 auto;
}
img.moon {
position: relative;
left: 900px;
bottom: 0px;
}
jquery:
$(document).ready(function(){
$('.moon').css('opacity', 0.4);
$('.moon').click(function(){
$(this).find('img').stop().fadeTo('slow',1);
});
});
最初の行は機能します。画像は不透明度0.4から始まります。次の部分は問題です。その中のコードは機能しません。2行目を$('*').click(function() {
(クラスを削除して「*」を入力)に変更し、Webサイトをランダムにクリックすると、画像がフェードインします。画像クラスを入力して画像をクリックすると、機能しません。
デモ.find()
コードから削除すると、すべて完了です。
$(document).ready(function() {
$('.moon').css('opacity', 0.4);
$('.moon').click(function() {
$(this).stop().fadeTo('slow',1);
});
});
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加