English 中文(简体)
显示/ 隐藏图像旋转 href 的需要按钮, 添加到 Javascript 代码中
原标题:Need button for show/hide image rotation href added to javascript code

我有以下脚本, 当您单击 div 中的图像时, 它会在新窗口中打开相应的 href 链接。 同时, 在父页上单击的 div 会被隐藏, 下一个 div 将会被显示 。

还有一个“ 下一步” 按钮, 所以为了在不单击图像的情况下向下一个 div 前进。 此“ 下一步” 按钮在当前 div 上不打开相应的 href 。 它跳到下一个 div 上 。

这一切都是完全正常的, 但我现在想添加一个按钮, 当点击时, 将会将您带到可见的 div 的 href 位置 。

这合情合理吗?

http://jsfiddle.net/QTyRq/" rel="nofollow">http://jsfiddle.net/QTyRq/

这里的代码是...

<div id="container">
    <div class="imgrotation"><a href="http://google.com" target="_blank"><img src="abc.jpg" width="100" height="100" border="0" /></a></div>
    <div class="imgrotation"><a href="http://yahoo.com" target="_blank"><img src="def.jpg" width="200" height="200" border="0" /></a></div>
    <div class="imgrotation"><a href="http://msn.com" target="_blank"><img src="ghi.jpg" width="300" height="300" border="0" /></a></div>
    <div class="imgrotation"><a href="http://bing.com" target="_blank"><img src="jkl.jpg" width="400" height="400" border="0" /></a></div>
</div>

<button id="nextimg">Next Image</button>

<!--This is what I need added to JS -->
<button id="gotourl">Visit Site</button>

杰克里:

var alldoneURL =  next-image-group.html ; //final click
function next(event, duration) {
    duration = duration || 900; // default value
    var that = $( .imgrotation:visible );
    if (that.next( .imgrotation ).length) {
        that.fadeOut(duration, function() {
            that.next( .imgrotation ).fadeIn(duration);
        });
    } else {
        window.location.href = alldoneURL;
    }
    return false;
}

$( .imgrotation ).not( :first ).hide();
$( .imgrotation a ).click(

function(e) {
    e.preventDefault();
    var newWin = window.open(this.href), //(this.href,  newWindow ) to load all clicks in one window.open
        duration = 900;
    next(e, duration);
});
$( #nextimg ).click(next);

最佳回答

添加此jquery 也会有效

$( #gotourl ).on( click ,function(){
      window.open($(".imgrotation:visible a").prop( href ));
});

​ ​

http://jsfiddle.net/QTyRq/3/

function$( #gotourl ).on( click ,function(){
    window.open($(".imgrotation:visible a").prop( href ));
    $( #nextimg ).trigger( click );
});

< a href=" "http://jsfiddle.net/QTyRq/4/" rel = "no follow" > 更新了JSFIDDLE, 两者都

问题回答

暂无回答




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

热门标签