English 中文(简体)
检测链接类已更改 [重复]
原标题:Detecting that a link class has changed [duplicate]
  • 时间:2012-05-24 13:27:18
  •  标签:
  • jquery
  • class
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
Class name change Event in jQuery

我正用支架在Bxsilder旁边

我需要在链接上辨识一个班级变化, 然后沿着线动画。

On page load div1 .pager-active moves the image along the line to left: 15% When next is pressed the link under div2 gets the class .pager-active and so on.

所以我需要jquery 来确认 div2 现在有班级. pager 活动, 以动画 Ing 到左: 50% 。

以下是我一直在研究的代码, 用于 div1 的初始负荷, 但没有检测到任何类别在负载后的变化 。

if( $( #div1 .pager-active ).length){
    $( .line img ).animate({ left  :  15% },600);
        };

if( $( #div2 .pager-active ).length){
    $( .line img ).animate({ left  :  50% },600);
        };

if( $( #div3 .pager-active ).length){
    $( .line img ).animate({ left  :  85% },600);
        };

任何帮助都将是巨大的。

问题回答

您可以在此获取班级变更事件 : @ info: whatsthis

< a href=" "https://stackoverflow.com/ questions/3139608/lasks-name-change-event-in-jquery" >在jQuery 中更改名称的事件

但您也可以尝试这个解决方案 :

When next is pressed, get id of div having class .pager-active . Use getAttr() for this. Once you have the id, remove it s class, attach class to next div in line and perform the effect.

var oldClass = $("#div").attr( class );
if(oldClass != $("#div").attr( class );
{
 //Do something?
}

类似的东西,也许?

尝试 DOMAttr 修改 事件 :

document.getElementsById( div2 ).addEventListener( DOMAttrModified , function(e){
  if (e.attrName ===  style ) {
    ...
  }
}, false);




相关问题
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: &...

热门标签