将鼠标悬停在其他按钮jquery上时更改img src

时间:2017-10-05 14:22:17

标签: javascript jquery html

我正在尝试调整网站的侧面图像,每个按钮都应该将图像更改为不同的src,我试过这个:

$(document).ready(function(){

   $("#introID").hover(function(){
        $("#frame").attr("src", "newImage.png");
   });
});

和其他一些变化,但由于某种原因,jquery没有捕获?或者也许是我的语法?从我的理解中我只需要

这是我的HTML:

<html>
<head>
<meta charset="utf-8">
<title>CAPP</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    $(document).ready(function(){

    $("#introID").hover(function(){
        $("#frame").attr("src", "assets/images/much-more-than-gasoline.png");
    });
});


</script>
<body>

<div id="logodiv">
<img id="logo" src="logo.png" alt="logo"/>
</div>

<div id="h1s">
<img src = "Origionalimage.png" id="frame"/>

    <div class="h1padding"></div>
    <a class = "h1" href="" id="introID">Intro</a>

    <div class="h1padding"></div>
    <a class = "h1" href="">ON THE <span class="light">SURFACE</span></a>

    <div class="h1padding"></div>
    <a class = "h1" href="">From <span class="light">ore to oil</span></a>

    <div class="h1padding"></div>
    <a class = "h1" href="">Environmental <span class="light">care</span></a>

    <div class="h1padding"></div>
    <a class = "h1" href="">Much more than <span class="light">gasoline</span></a>

    <div class="h1padding"></div>
    <a class = "h1" href="">One more <span class="light">thing</span></a>

</div>




</body>

提前致谢:)

1 个答案:

答案 0 :(得分:0)

如果设置了#Import the necessary methods from tweepy library from tweepy.streaming import StreamListener from tweepy import OAuthHandler from tweepy import Stream #Variables that contains the user credentials to access Twitter API access_token = 'X3YIzD' access_token_secret = 'PiwPirr' consumer_key = 'ekaOmyGn' consumer_secret = 'RkFXRIOf83r' #This is a basic listener that just prints received tweets to stdout. class StdOutListener(StreamListener): def on_data(self, data): print data return True def on_error(self, status): print status if __name__ == '__main__': #This handles Twitter authetification and the connection to Twitter Streaming API l = StdOutListener() auth = OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) stream = Stream(auth, l) #This line filter Twitter Streams to capture data by the keywords: 'python', 'javascript', 'ruby' stream.filter(track=['python', 'javascript', 'ruby']) 属性,则不得在script代码中嵌入自己的脚本。

src

这应该可以解决问题。 Here您会找到更多信息。