Jquery - 需要有关使用方面的帮助

时间:2012-06-18 04:50:42

标签: php jquery

这是在jquery函数中使用php脚本的正确方法吗? pathToTabImage变量

<script type="text/javascript">
    $(function(){
        $('.slide-out-div').tabSlideOut({
            tabHandle: '.handle',                     //class of the element that will become your tab
            pathToTabImage: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/ack.jpg';, //path to the image for the tab //Optionally can be set using css
            alert(pathToTabImage);
            imageHeight: '122px',                     //height of tab image           //Optionally can be set using css
            imageWidth: '125px',                       //width of tab image            //Optionally can be set using css
            tabLocation: 'right',                      //side of screen where tab lives, top, right, bottom, or left
            speed: 600,                               //speed of animation
            action: 'click',                          //options: 'click' or 'hover', action to trigger animation
            topPos: '600px',                          //position from the top/ use if tabLocation is left or right
            leftPos: '550px',                          //position from left/ use if tabLocation is bottom or top
            fixedPosition: false                      //options: true makes it stick(fixed position) on scroll
        });

    });

2 个答案:

答案 0 :(得分:0)

删除分号。

/images/ack.jpg';,

/images/ack.jpg',

此外,这个alert也没有给你任何好处,也需要去。

alert(pathToTabImage);

答案 1 :(得分:-1)

这是注入PHP代码的可行方法之一,内部为HTML,CSS或JS Document / Snippet。但是,从语法上讲,错误很少。

PHP错误

<?php echo $this->baseurl ?>

最后声明中没有selicolon

JavaScript错误

pathToTabImage: '...';, //...

不需要的分号,以不正确的方式结束陈述

alert(pathToTabImage);

在另一个陈述中注入一个独立的陈述