Question: Imagine I'm building a blog system where a user can upload images for a blog post. I have a problem mapping the uploaded images with user and their blog post.

Here's the flow :

1. User uploaded some pictures, it's saved to the server.
2. I store the image name in the related table, means later I can
retrieve images by blog's post\_id.

But what if the user upload images that has the same file name?

Answer: 
You can do the fading with just css transitions all you need to do is use jquery toggleClass function when the window reaches 150px.

Try the following: 

```
$(window).on( "scroll", function() {
   $('#secondNav').toggleClass('scrolled', $(this).scrollTop() > 150);
});

```

and the css 

```
#secondNav.navbar-default{
  background: #000;
  transition: background-color 0.5s ease;
}
#secondNav.scrolled {
  background: rgba(0,0,0,0.5);
}

```

The transition property is what will give you the fade in and out and then you can change the background of the navbar-default to whatever you want it to be. When it reaches 150px it will toggle the scrolled class and change the background.
Are you using jQuery? if so, maybe something like this?

```
$('#div').click(() => {
    $('#div').fadeOut();

  $('#div')
  .css('background-color', 'green')
  .fadeIn();

});

```

<https://jsfiddle.net/53n2o76g/>