我想在datalist图像的鼠标悬停事件上更改图像 [英] i would like to change image on mouseover event of a datalist image

查看:100
本文介绍了我想在datalist图像的鼠标悬停事件上更改图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:DataList ID =DataList6runat =serverRepeatDirection =Vertical>

< itemtemplate>



< asp:Image ID =Image1runat =server

Height =62pxWidth =82pxImageUrl ='<%#Bind(main_image)% >'/>











< asp:图片ID =完整图片runat =serverHeight =450pxWidth =350pxImageUrl =a.jpg/>













在这里,我会要在'image1'鼠标悬停事件中将'完整图像'图像转换为'image1'图像,请提供有用的代码。

解决方案

我建​​议您使用Jquery



在鼠标悬停时更改图像

您可以使用JavaScript或JQuery。我已经展示了使用JQuery。必须使用时,将JQuery(.JS)文件放在页面中。如果您没有.JS文件而不是从下面的代码下载。



http: //jquery.com/download/ [ ^ ]



将以下所有代码放在脚本标记内。

首先拍摄图像的路径,如下图所示。



  var  Imagesrc = 


' #Image1')。attr( src);





现在使用该变量来分配另一个图像的来源,如如下所示。

 


<asp:DataList ID="DataList6" runat="server" RepeatDirection="Vertical">
<itemtemplate>

<asp:Image ID="Image1" runat="server"
Height="62px" Width="82px" ImageUrl='<%# Bind("main_image") %>'/>





<asp:Image ID="full image" runat="server" Height="450px" Width="350px" ImageUrl="a.jpg"/>






Here , i would to convert 'full image' imageurl to 'image1' imageurl on 'image1' mouseover event, please provide me with useful code.

解决方案

i suggest you to use Jquery

changing image on mouseover


Hi, you may either use JavaScript or JQuery. I have shown using JQuery. Place JQuery(.JS) file in the page when you have to use it. If you don't have .JS file than download from below code.

http://jquery.com/download/[^]

Place all below code within script tag.
First take the path of the image, such as below.

var Imagesrc =


('#Image1').attr("src");



Now use that variable to assign the source of the another image, as shown below.


这篇关于我想在datalist图像的鼠标悬停事件上更改图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆