Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 全屏背景图像_Jquery_Css - Fatal编程技术网

Jquery 全屏背景图像

Jquery 全屏背景图像,jquery,css,Jquery,Css,我已经有了背景图像。但我在建一个画廊,有不同的类别。如果我选择一个类别,图像将加载在小正方形中,然后当我选择其中任何一个时,我希望它更改命名id的内容 e、 g。 任何好的建议都将不胜感激 我想做的是两件事 将导航框的颜色更改为纯色 单击时更改id“grouptabs”的图像源 这就是我想说的。。。 感谢您的所有建议假设您已存储该类别的背景信息。比如通过jQuery.data() 那么你需要做的就是 $('.category').click(function(){ var thisEl

我已经有了背景图像。但我在建一个画廊,有不同的类别。如果我选择一个类别,图像将加载在小正方形中,然后当我选择其中任何一个时,我希望它更改命名id的内容

e、 g。

任何好的建议都将不胜感激

我想做的是两件事

  • 将导航框的颜色更改为纯色

  • 单击时更改id“grouptabs”的图像源

    
    

  • 这就是我想说的。。。
    感谢您的所有建议

    假设您已存储该类别的背景信息。比如通过jQuery.data()

    那么你需要做的就是

    $('.category').click(function(){
      var thisElem = $(this)
      $('#myBackround').css({background-image:"url('"+thisElem.data('backgroundImagePath')+"')"})
    })
    
    此示例演示如何更改dom元素的背景图像。但是,如果要更改内容,可以使用
    jQuery.html()
    而不是
    jQuery.css()

    作为旁注,您还可以将当前单击的类别设置为另一个不透明度级别,以显示这是选定的元素

    然后你会做这样的事情:

    $('.category').click(function(){
      var thisElem = $(this)
      //remove active effect on any previously selected categories
      thisElem.siblings().removeClass('activeCategory')
      //add active effect to currently selected category
      thisElem.addClass('activeCategory')
    
      $('#myBackround').css({
            background-image:"url('"+thisElem.data('backgroundImagePath')+"')"
      })
    
    })
    
    您可以在其中拥有css属性

    .activeCategory {
      opacity: 0.5;
      background-color: #f60;
    }
    

    假设您已存储类别的背景信息。比如通过jQuery.data()

    那么你需要做的就是

    $('.category').click(function(){
      var thisElem = $(this)
      $('#myBackround').css({background-image:"url('"+thisElem.data('backgroundImagePath')+"')"})
    })
    
    此示例演示如何更改dom元素的背景图像。但是,如果要更改内容,可以使用
    jQuery.html()
    而不是
    jQuery.css()

    作为旁注,您还可以将当前单击的类别设置为另一个不透明度级别,以显示这是选定的元素

    然后你会做这样的事情:

    $('.category').click(function(){
      var thisElem = $(this)
      //remove active effect on any previously selected categories
      thisElem.siblings().removeClass('activeCategory')
      //add active effect to currently selected category
      thisElem.addClass('activeCategory')
    
      $('#myBackround').css({
            background-image:"url('"+thisElem.data('backgroundImagePath')+"')"
      })
    
    })
    
    您可以在其中拥有css属性

    .activeCategory {
      opacity: 0.5;
      background-color: #f60;
    }
    

    一般来说,这就是您要寻找的:

    $('.thumbnail').click(function(e) {
      e.preventDefault(); // don't execute the link
      $(.thumbnail').css('background-color', 'none'); // reset all BG colors
      $(this).css('background-color', '#00FF00'); // fill BG of clicked elements parent (the p-element).
    
      var imghref = $(this).attr('href'); // get the image src from the href
      $('#grouptabs').attr('src', imghref);  // set the image src for #grouptabs
    });
    
    这适用于以下设置:

    1. 2. 3. 4. 因此,图像将加载到grouptab中(全尺寸)。在CSS中,您应该指定类缩略图中的a元素具有边框且没有bgcolor。BG颜色由jquery单击事件处理

    希望这能有所帮助

    //
    编辑
    :尝试以下操作:

    $('.crafty').click(function(e) {
      e.preventDefault();
      $('.foliolist').css('background-color', 'transparant'); // set all foliolist items bg color to transparant
      $(this).parent().css('background-color', '#FFFFFF');
      $('#grouptabs').attr('src', $(this).attr('href'));
    });
    
    我不确定您是否正在使用此设置:

    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    
    
    

    
    

    因为有区别。在第一种情况下,我的脚本可以工作。在第二种情况下,您需要将样式(背景色)应用于$(this)而不是$(this).parent()

    通常这就是您要查找的:

    $('.thumbnail').click(function(e) {
      e.preventDefault(); // don't execute the link
      $(.thumbnail').css('background-color', 'none'); // reset all BG colors
      $(this).css('background-color', '#00FF00'); // fill BG of clicked elements parent (the p-element).
    
      var imghref = $(this).attr('href'); // get the image src from the href
      $('#grouptabs').attr('src', imghref);  // set the image src for #grouptabs
    });
    
    这适用于以下设置:

    1. 2. 3. 4. 因此,图像将加载到grouptab中(全尺寸)。在CSS中,您应该指定类缩略图中的a元素具有边框且没有bgcolor。BG颜色由jquery单击事件处理

    希望这能有所帮助

    //
    编辑
    :尝试以下操作:

    $('.crafty').click(function(e) {
      e.preventDefault();
      $('.foliolist').css('background-color', 'transparant'); // set all foliolist items bg color to transparant
      $(this).parent().css('background-color', '#FFFFFF');
      $('#grouptabs').attr('src', $(this).attr('href'));
    });
    
    我不确定您是否正在使用此设置:

    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    <div class="foliolist"><a href="img/dir/file.jpg"></a></div>
    
    
    

    
    

    因为有区别。在第一种情况下,我的脚本可以工作。在第二种情况下,您需要将样式(背景色)应用于$(this)而不是$(this).parent()

    您的问题非常令人困惑。我想如果你想把你的问题修改得更清楚一些,你会更幸运地得到答案。你的问题很令人困惑。我想如果你想把你的问题修改得更清楚一些,你会更幸运地得到答案。我的问题有点不对劲,我打字的时候在键盘上睡着了。我想做的是两件事。很抱歉,当我点击return时我没有看。。。我想做的是两件事。1.将导航框的颜色更改为纯色。2.更改单击时id的图像源很抱歉,当我单击return时我没有查看。。。我想做的是两件事。1.将导航框的颜色更改为纯色。2.单击
    时更改id“grouptabs”的图像源谢谢
    $(“#random”).css('background-color','#00FF00')(插入自己的颜色)和
    $('grouptabs').attr('src','new/source/here.jpg')谢谢,在循环浏览我的20个项目之前,我该如何写出来呢。谢谢你的帮助。我的问题有点离题了。我打字的时候在键盘上睡着了。我想做的是两件事。很抱歉,当我点击return时我没有看。。。我想做的是两件事。1.将导航框的颜色更改为纯色。2.更改单击时id的图像源很抱歉,当我单击return时我没有查看。。。我想做的是两件事。1.将导航框的颜色更改为纯色。2.单击
    时更改id“grouptabs”的图像源谢谢
    $(“#random”).css('background-color','#00FF00')(插入自己的颜色)和
    $('grouptabs').attr('src','new/source/here.jpg')谢谢,在循环浏览我的20个项目之前,我该如何写出来呢。谢谢你的帮助。