为什么这一个jquery工作而另一个没有

时间:2014-03-01 17:09:39

标签: javascript php jquery

我正在创建一个cms并且正在使用php动态创建jquery。当php在我的代码中呈现jquery inlce时,下面的第一个工作正常,但是第二个只有当我放在我的js函数脚本上时才会工作,该脚本被调用到页面的标题中:

# start index video row
    echo '<script type="text/javascript">';
    echo "$('#indexVid').fancybox({"; echo " \n";
    echo "'width' : '75%',"; echo " \n";
    echo "'height' : '75%',"; echo " \n";
    echo "'autoScale' : true,"; echo " \n";
    echo "'transitionIn' : 'elastic',"; echo " \n";
    echo "'transitionOut' : 'elastic',"; echo " \n";
    echo "'type' : 'iframe'"; echo " \n";
    echo "});"; echo " \n"; 
    echo '</script>';

# open help
    echo '<script type="text/javascript">'; 
    echo '$("#open_testing").click( function(){ $("#info_testing").css("display","block"); } );'; echo " \n";
    echo '$("#close_testing").click( function(){ $("#info_testing").css("display","none"); } );'; echo " \n";   
    echo '</script>';


                    $name = 'testing';
            $this_label = 'Learn about Site Settings';
            $info = 'Site Settings are variable aspects of the site which are common to all or most all of the pages on the site such as copyright information and such, or they are miscellaneous variables necessary to a specific aspects of the site such as the send mail limitation. To find out more about each click on the info icon.';

            <p id="open_'.$name.'" class="info-link"><i class="icon-info-sign"></i> '.$this_label.'</p>

            <div id="info_'.$name.'" class="hide info-wrap">
            <h3>'.$this_label.'</h3>
            echo $info;
            <p class="center"><a id="close_'.$name.'" class="button small"  title="Close Info Panel">
            <i class="icon-remove-sign"> </i> Close</a></p>
            </div>

html在

之上
$("#open_testing").click( function(){ $("#info_testing").css("display","block"); } );
    $("#close_testing").click( function(){ $("#info_testing").css("display","none"); } );

如果上面的jquery在标题中,但是如果代码中的内联

则不行

可以解释一下为什么吗?感谢

0 个答案:

没有答案