user3052410
user3052410

Reputation: 3

get a dynamic value for css

I'm new here so i'll ask. I have a dynamic slider that gets the height dynamically. So I need to get this dynamic height and pass the value to the top css.

I added this function in the function.js file

$('.navbar-inverse').css("top", 922);

and it gets the value, but I need this value to be dynamic and not inserted manually.

The height value comes from a class name fs-stretcher

Any help would be great. tks

Upvotes: 0

Views: 166

Answers (2)

Deryck
Deryck

Reputation: 7658

This needs to be part of an event handler if you want the dynamic value. You call it a slider but I'm not sure what exactly the event is so we'll go with...scrolling down the page (just change the word scroll to whatever you use).

$('.navbar-inverse').on('scroll', function() {
    $(this).css('top', $('.fs-stretcher').height());
});

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

Try

$('.navbar-inverse').css("top", $('.fs-stretcher').height())

Upvotes: 2

Related Questions