从JavaScript文件调用rel for anchor?

时间:2015-01-05 02:13:34

标签: javascript jquery html asp.net

我有一个调用JS文件的asp.net文件 问题是 当我从aspx页面调用anchor属性时,它正确显示 但是当我试图从js文件中调用它时它会起作用

我的代码为 aspx页面

      <ul id="gallery_id">
                <li class="first">
                    <img src="images/demo/gallery/1.jpg" alt="Title Text" /></li>
                <li><a href="images/demo/gallery/2.jpg" rel="prettyPhoto[gallery1]" title="Image 1">
                    <img src="images/demo/gallery/2.jpg" alt="Title Text" /></a></li>
                <li><a href="images/demo/gallery/3.jpg" rel="prettyPhoto[gallery1]" title="Image 2">
                    <img src="images/demo/gallery/3.jpg" alt="Title Text" /></a></li>
                <li><a href="images/demo/gallery/4.jpg" rel="prettyPhoto[gallery1]" title="Image 3">
                    <img src="images/demo/gallery/4.jpg" alt="Title Text" /></a></li>
                <li><a href="images/demo/gallery/572x330.gif" rel="prettyPhoto[gallery1]" title="Image 4">
                    <img src="images/demo/gallery/174x150.gif" alt="Title Text" /></a></li>

            </ul>

当我试图从js文件动态调用它时 如

 function view_gallery(response) {
        if (response != null) {
            for (var i = 0; i < response.length; i++) {
                if (i == 0) {
                    $('#gallery_id').append($('<li id=\"' + response[i].image_guid + '\" class=\"first\" >                        ' +
                            '<img src=\"../images/demo/gallery/' + response[i].image_location + '\" alt=\"' + response[i].image_location + '\" /></li>'));
                }
                else {
                    $('#gallery_id').append($('<li id=\"' + response[i].image_guid + '\">' +


                        '  <a href=\"../images/demo/gallery/' + response[i].image_location+'"'
                        + ' rel=\"prettyPhoto[gallery1]\" title=\"Image 1\">' +

                          ' <img src=\"../images/demo/gallery/' + response[i].image_location
                        + '\" alt=\"Title Text\" /></a></li>'));

                }

我的asp插件是:

<script type="text/javascript" src="layout/scripts/jquery.min.js"></script>
<script type="text/javascript" src="layout/scripts/jquery.ui.min.js"></script>
<script type="text/javascript" src="layout/scripts/jquery.defaultvalue.js"></script>
<script type="text/javascript" src="layout/scripts/jquery.scrollTo-min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#fullname, #validemail, #message").defaultvalue("Full Name", "Email Address", "Message");
        $('#shout a').click(function () {
            var to = $(this).attr('href');
            $.scrollTo(to, 1200);
            return false;
        });
        $('a.topOfPage').click(function () {
            $.scrollTo(0, 1200);
            return false;
        });
        $("#tabcontainer").tabs({
            event: "click"
        });
        $("a[rel^='prettyPhoto']").prettyPhoto({
            theme: 'dark_rounded'
        });
    });
</script>
<!-- prettyPhoto -->
<link rel="stylesheet" href="layout/scripts/prettyphoto/prettyPhoto.css" type="text/css" />
<script type="text/javascript" src="layout/scripts/prettyphoto/jquery.prettyPhoto.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("a[rel^='prettyPhoto']").prettyPhoto({
            theme: 'dark_rounded',
            overlay_gallery: false,
            social_tools: false
        });
    });
</script>

     <script type="text/javascript" src="javascript/gallery.js"></script>

它显示图像但忽略了锚元素的rel值

请帮助

0 个答案:

没有答案