开发者

How to write this JavaScript if-else statement

I'm currently using the backstretch.js script for full screen background images, I've got it working but I would like to add an if statement to check if an image is set, which are set via custom post types display that image, if not, the default image should be link to image

This is what I have so far, but it doesn't work and need help fixing it:

<script src="<?php bloginfo('template_url'); ?>/js/jquery.backstretch.js"></script>
<script>
    var link = $.back开发者_运维百科stretch(
        "<?php echo get_post_meta($post->ID, 'upload_image', true); ?>")
    var altLink = '<?php bloginfo('template_url'); ?>/images/not-set-default.jpg'
    if (x == link) {
        document.write(link)
    } else {
        document.write(altLink)
    }
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜