-3

我在 jquery 中有一个站点,在标题中有一个静态图像,当我单击以更改 jquery 中的内容时,我想更改它。

网站:http ://swapes.com/intech2

我怎么能这样做?(我没有示例代码,因为我不知道如何开始)

谢谢

4

2 回答 2

0

原理很简单:

$("#img_id_here").click(function(){
    //do modifications here
})

编辑:如果您想编辑图像源,如上例所示,但是当单击图像时(按指定),您可以执行以下操作:

$("#img_id_here").click(function(){
    $(this).attr('src', 'new_source_for_image');
})

以上内容应添加到您的 javascript 文件中。作为替代方案,您可以将以下内容添加到您的 HTML(或 PHP)文件中:

<script>$("#img_id_here").click(function(){$(this).attr('src', 'new_source_for_image');})</script>
于 2013-07-28T14:39:21.997 回答
0

如果您正在使用<img>标签,并且您给它一个 ID:

<img id='headerImage' src='...' />

在 jquery 中你可以这样做:

$("#headerImage").attr('src', 'new.img.src');
于 2013-07-28T14:41:59.200 回答