在javascript中更改方向

在javascript中更改方向,javascript,Javascript,在我的网站上有一个主滑块的javascript代码,所有移动文本的方向都是从左到右。我如何将其更改为从右到左 <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.min.js"></script> <script type="text/javascript" src="<?php echo get_template_di

在我的网站上有一个主滑块的javascript代码,所有移动文本的方向都是从左到右。我如何将其更改为从右到左

<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.min.js"></script>
    <script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.easing.1.3.js"></script>
    <script type="text/javascript">
        $(function() {
            var current = 1;

            var iterate     = function(){
                var i = parseInt(current+1);
                var lis = $('#rotmenu').children('li').size();
                if(i>lis) i = 1;
                display($('#rotmenu li:nth-child('+i+')'));
            }
            display($('#rotmenu li:first'));
            /* In intervals of 5 seconds jump to the next element */
            var slidetime = setInterval(iterate,5000);

            $('#rotmenu li').bind('click',function(e){
                clearTimeout(slidetime);
                display($(this));
                e.preventDefault();
            });

            function display(elem){
                var $this   = elem;
                var repeat  = false;
                if(current == parseInt($this.index() + 1))
                    repeat = true;

                if(!repeat)
                    $this.parent().find('li:nth-child('+current+') a').stop(true,true).animate({'marginRight':'-20px'},300,function(){
                        $(this).animate({'opacity':'0.7'},700);
                    });

                current = parseInt($this.index() + 1);

                var elem = $('a',$this);

                    elem.stop(true,true).animate({'marginRight':'0px','opacity':'1.0'},300);

                var info_elem = elem.next();
                $('#rot1 .heading').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
                    $('h1',$(this)).html(info_elem.find('.info_heading').html());
                    $(this).animate({'left':'0px'},400,'easeInOutQuad');
                });

                $('#rot1 .description').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
                    $('p',$(this)).html(info_elem.find('.info_description').html());
                    $(this).animate({'bottom':'0px'},400,'easeInOutQuad');
                })
                $('#rot1').prepend(
                $('<img/>',{
                    style   :   'opacity:0',
                    className : 'bg'
                }).load(
                function(){
                    $(this).animate({'opacity':'1'},600);
                    $('#rot1 img:first').next().animate({'opacity':'0'},700,function(){
                        $(this).remove();
                    });
                }
            ).attr('src','<?php echo get_template_directory_uri(); ?>/images/'+info_elem.find('.info_image').html()).attr('width','800').attr('height','300')
            );
            }
        });
    </script>

您需要将marginRight替换为marginLeft


此外,您还需要在正文和文本对齐方式中对类似Css的方向进行一些更改,请尝试以下代码。我已经将文本流的位置改为两行,并添加了注释,因此您可以很容易地找到它们

<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/jquery.easing.1.3.js"></script>
<script type="text/javascript">
    $(function() {
        var current = 1;

        var iterate     = function(){
            var i = parseInt(current+1); 
            var lis = $('#rotmenu').children('li').size();
            if(i>lis) i = 1;
            display($('#rotmenu li:nth-child('+i+')'));
        }
        display($('#rotmenu li:first'));
        /* In intervals of 5 seconds jump to the next element */
        var slidetime = setInterval(iterate,5000);

        $('#rotmenu li').bind('click',function(e){
            clearTimeout(slidetime);
            display($(this));
            e.preventDefault();
        });

        function display(elem){
            var $this   = elem;
            var repeat  = false;
            if(current == parseInt($this.index() + 1)) 
                repeat = true;

            if(!repeat)
                $this.parent().find('li:nth-child('+current+') a').stop(true,true).animate({'marginRight':'-20px'},300,function(){
                    $(this).animate({'opacity':'0.7'},700);
                });

            current = parseInt($this.index() = 1); 

            var elem = $('a',$this);

                elem.stop(true,true).animate({'marginRight':'0px','opacity':'1.0'},300);

            var info_elem = elem.next();
            $('#rot1 .heading').animate({'right':'-420px'}, 500,'easeOutCirc',function(){  //changed left to right
                $('h1',$(this)).html(info_elem.find('.info_heading').html());
                $(this).animate({'right':'0px'},400,'easeInOutQuad'); //changed left to right
            });

            $('#rot1 .description').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
                $('p',$(this)).html(info_elem.find('.info_description').html());
                $(this).animate({'bottom':'0px'},400,'easeInOutQuad');
            })
            $('#rot1').prepend(
            $('<img/>',{
                style   :   'opacity:0',
                className : 'bg'
            }).load(
            function(){
                $(this).animate({'opacity':'1'},600);
                $('#rot1 img:first').next().animate({'opacity':'0'},700,function(){
                    $(this).remove();
                });
            }
        ).attr('src','<?php echo get_template_directory_uri(); ?>/images/'+info_elem.find('.info_image').html()).attr('width','800').attr('height','300')
        );
        }
    });
</script>

javascript代码是object.style.direction-在jQuery中应该是.css(“direction”)你的意思是我必须更改css代码而不是javascript?css代码已经更改,但关于动画方向,我更改了marginRight,什么都没有…谢谢,但什么都没有发生你可以发布完整的代码-html,css和javascript,这样我就可以使用它了。我如何发布它?我可以收到你的电子邮件吗?转到www.jsfiddle.net,将代码放入,保存,复制生成的url并粘贴到这里。