简体   繁体   English

更改按钮并单击div

[英]Change button and div on click

Hello I need to mimic this websites function with the "view 360" button: http://www.designrattan.co.uk/daybed/apple 您好,我需要使用“查看360”按钮模仿此网站功能: http : //www.designrattan.co.uk/daybed/apple

I have already got the 360 script worked out it is JUST THE BUTTON that I cannot work out? 我已经解决了360脚本,只是按钮无法解决?

I have attempted it here: http://designliving.tk/winchester-rattan-garden-round-table-set 我在这里尝试过: http : //designliving.tk/winchester-rattan-garden-round-table-set

but several things are wrong as you can see. 但是您可以看到有些错误。

I need the DIV to change when clicking the button, but I also need the button to change every time it is clicked (from "view 360" to "view image"). 单击按钮时,我需要更改DIV,但是每次单击按钮时,我也需要更改按钮(从“视图360”更改为“视图图像”)。

In addition to that I need the images in my photos tab to be able to change the div and button back to "view 360" 除此之外,我还需要“照片”标签中的图像才能将div和按钮更改回“ view 360”

I think I have the JavaScript but I dont know how to use this in conjunction with HTML 我想我有JavaScript,但是我不知道如何与HTML结合使用

$('.yourButton').bind('click',function(){
if (!$('.yourButton').hasClass('dragMode')) {
    $('.yourButton').addClass('dragMode');
    $('.yourButton').attr('value')="Drag [...]";
} else { // if in drag mode
    $('.yourButton').removeClass('dragMode');
    $('.yourButton').attr('value')="View 360";
}
});

$('.yourTabImages').bind('click',function(){
if ($('.yourButton').hasClass('dragMode')) {
    $('.yourButton').removeClass('dragMode');
    $('.yourButton').attr('value')="View 360";
}
});

I hope this all makes sense!, 我希望这一切都有道理!,

Thanks everyone! 感谢大家!

If you use jquery, it can be easily achieved with something like : 如果您使用jquery,则可以通过类似以下内容轻松实现:

$('.yourButton').bind('click',function(){
    if (!$('.yourButton').hasClass('dragMode')) {
        $('.yourButton').addClass('dragMode');
        $('.yourButton').attr('value')="Drag [...]";
    } else { // if in drag mode
        $('.yourButton').removeClass('dragMode');
        $('.yourButton').attr('value')="View 360";
    }
});

$('.yourTabImages').bind('click',function(){
    if ($('.yourButton').hasClass('dragMode')) {
        $('.yourButton').removeClass('dragMode');
        $('.yourButton').attr('value')="View 360";
    }
});

This way you can validate in which mode your button is when choosing which method to call when handling the click event. 这样,您可以在选择单击事件时选择要调用的方法时验证按钮处于哪种模式。 Hope this helps 希望这可以帮助

Dont implement you own code, that will take time. 不要实现自己的代码,这将需要时间。 Use this any of plugin which you like: http://www.jquery4u.com/plugins/jquery-360-degrees-image-display-plugins/#.T_wDU5GFp9g 使用任何您喜欢的插件: http : //www.jquery4u.com/plugins/jquery-360-degrees-image-display-plugins/#.T_wDU5GFp9g

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM