English 中文(简体)
• 如何改变形象。 jpg with jQuery?
原标题:How to change an image with a hover.jpg with jQuery?
  • 时间:2011-05-10 16:34:05
  •  标签:
  • jquery
  • hover

我的产出如下。

<ul id= centrelist >
<li class="centreicon"><a href="admin/manage_mycentre/22"><img width= 70  height= 70  class= centreimg  src="http://localhost/aktivfitness_new/assets/images/centre/centre1.jpg" /></a><div class="buttons"><a href="admin/manage_mycentre/22">Aktiv trening Arendal</a></div></a></li>
<li class="centreicon"><a href="admin/manage_mycentre/16"><img width= 70  height= 70  class= centreimg  src="http://localhost/aktivfitness_new/assets/images/centre/centre2.jpg" /></a><div class="buttons"><a href="admin/manage_mycentre/16">Aktiv trening Blindheim</a></div></a></li>
<li class="centreicon"><a href="admin/manage_mycentre/17"><img width= 70  height= 70  class= centreimg  src="http://localhost/aktivfitness_new/assets/images/centre/centre3.jpg" /></a><div class="buttons"><a href="admin/manage_mycentre/17">Aktiv trening Eid</a></div></a></li>
...

现在,当我放弃任何形象时,我想改变这种形象。 jpg with jquery.

我有以下几个方面,但我没有工作。

$(function() {
    $(".centreimg")
        var orgimg = $(this).attr("src");
        .mouseover(function() {
            var hoverimg = $(this).attr("src").match(/[^.]+/) + "hover.jpg";
            $(this).attr("src", hoverimg);
        })
        .mouseout(function() {
            $(this).attr("src", orgimg);
        });
});
问题回答

仅作少量更正

$(function() {
    $(".centreimg").mouseover(function() {
            var hoverimg = $(this).attr("src").match(/[^.]+/) + "hover.jpg";
            var orgimg = $(this).attr("src");

            $(this).attr("src", hoverimg);
            $(this).attr("title", orgimg);
        })
        .mouseout(function() {
            $(this).attr("src", $(this).attr("title"));
        });
});

您必须储存物体内的数据。

http://www.ohchr.org。

$( .centreimg ).hover( 
function() {
    $(this).data( src ,$(this).attr( src ));
    $(this).attr( src ,  hover.jpg  ); //or hoverimg if it is declared
},
function(){
    $(this).attr( src , $(this).data( src ) );
});




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签