English 中文(简体)
Jquerystart(点击)
原标题:Jquery trigger( click ) doesnt work in IE

I update this once again, this only fails in some versions of IE. It s something with the last line in the js code. "$($nextlink).trigger( click );" that some versions of IE can t handle... Is it possible to do a work around that will make sure it works in all IE versions?

这里是 j。

$(".trigger").live( click ,function() {
 if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } // to prevent default link to image, event.returnValue = false; for it to work in IE.
    var $currentId =$(this).attr( id ); //The Id of the clicked thumbnail
    var $newlink = $currentId +  .php ; //The new images in a .php file
    var $newcontent =  #  + $currentId +  box ; //Where to load
    var $nextlink =  #  + $(this).next().attr( id ); //The simulated click id
    $($newcontent).load($newlink, function() {
    $("a[rel^= prettyPhoto ]").prettyPhoto({animation_speed: fast ,theme: light_square ,slideshow:3000, autoplay_slideshow: false, hideflash: true, deeplinking:false});
$($nextlink).trigger( click );
    });
});

Html:

<li class="projectitem photo" data-id="id-1">
<div class="grid_1 projectbox">
<div class="boxcontain surf">
<a id="surf" class="trigger" href="img/_MG_8635.jpg"><img class="fade" src="img/thumb_surfbw.jpg" title="Surfing" style="background: url(img/thumb_surfcolor.jpg);" alt="Surfing" /></a>
<a id="surflink" class="hide" rel="prettyPhoto[surfing]" href="img/_MG_8635.jpg" title= <strong>Project: </strong>Photo gallery of my selected surf photos from Hawaii<br><strong>Year: </strong>2011<br><strong>Type: </strong>Photo ><img class="fade" src="img/thumb_surfbw.jpg" title="Surfing" style="background: url(img/thumb_surfcolor.jpg);" alt="Surfing" /></a>
<div id="surfbox" class="hide">blank</div>
<h4>Surfing</h4>
</div></div></li>

So basically two questions:

  1. Why is not the mouse click simulated in some IE versions?

  2. 为什么它不从事慈善工作? (我对这一事件有问题。) 防ault在火ox中进行,但现已固定,见下文。

See fully example on http://jgriph.se

最佳回答

Change

$(".trigger").live( click ,function() {
 if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }

纽约总部

$(".trigger").live( click ,function(event) {
 if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; }
问题回答

暂无回答




相关问题
Mysql trigger/events vs Cronjob

I have an auction website which let my users place an unlimited amount of autobiddings. To monitor these autobiddings something has to check the database every second. My question is if it is ...

Can an event be used as an event listener?

I m trying to expose some events from a private object which is contained inside the object I am creating and it looks like the compiler is happy with this: private WindowUpdateServer ...

鸡奸

由于将javascript DOM方法放在第html页底部(在<有人>之后)远比利用“j Query”准备活动要快得多,因此我们不得不这样做:

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

jQuery bind on ajax load() event

I have a page which displays multiple blocks with results details. Inside each block I have some <a> tags with thickbox jQuery plugin attached: class="thickbox" Here is an example of one kind ...

HTML text input event

I have a form, and want to disable/enable its submit button depending on whether the form s input text fields are empty or have had text entered into them. I think this means having an event handler ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签