English 中文(简体)
当活孩子被点击时,我如何解脱母子的浮标?
原标题:How do I disable the onclick of parent when live child is clicked?

因此,在我需要防止当儿童被点击时父母的缺席行动时,我通常只使用停止卖淫。 然而,这似乎与生活要素有关。 因此,我的想法是,当孩子被抓走时,暂时取消父母的lick。 我似乎能够将其删除,只是罚款,但我似乎不能把它补充到要素中。 这是我所谈到的。

$( body ).delegate( .button ,  mouseenter mouseout , function(e){
        if(e.type== mouseenter ){
          var inside = $(this).parents( .post ).attr( onclick );
          $(this).parents( .post ).attr( onclick ,  );
        }else if(e.type== mouseout ){
          $(this).parents( .post ).attr( onclick , inside);
        }
    })

So this will remove the element successfully, however the attempt to add it back is always unsuccessful... it just comes up empty. Can anyone give me a hand here? I m completely stuck. I d also be happy with alternative method to achieving the same result. Thank you.

最佳回答

http://jsfiddle.net/kDuNU/4/“rel=“nofollow” http://jsfiddle.net/kDuNU/4/:

$( div ).live( click , function(event) {
    if ($(event.target).hasClass( button ))
       return;
    alert( hello );
});

$( .a-span ).live( click , function (event) {
    alert($(this).text());
});
$( div ).append( <span class="a-span button">another</span> );

<div> hello <br/>
    <span class="a-span">world</span>
</div>
问题回答

类似情况:


if(e.type== mouseenter ){
    $(this).parents( .post ).unbind( click );
}else if(e.type== mouseout ){
    $(this).parents( .post ).bind( click );
}

//OR place your inside variable before if, like
var inside = $(this).parents( .post ).attr( onclick );  //placed outside of if
if(e.type== mouseenter ){   
   $(this).parents( .post ).attr( onclick ,  );
}else if(e.type== mouseout ){
   $(this).parents( .post ).attr( onclick , inside);
}

希望能为你们工作





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

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签