1

I have a small demo:

<div class="box_content_height">
    <strong>Height: </strong>
    <input type="text" name="height" id="height" value="300" />px
    <input type="submit" class="submit_advance" value="submit" />    
</div>

And javascript

$('.submit_advance').click(function() {
        var height_css = $('#height').val();
        $('ul.nav-scroll').css('max-height', height_css+'px');
});

When I type input = 500 is result css no change 500 How to result is

.ul.nav-scroll {
    max-height: valueofinput+px
}
2
  • max-height will only actually change the height of the DOM if the content exceeded that of the previous height. Commented Feb 15, 2012 at 3:13
  • It was working fine check this fiddle jsfiddle.net/kGSbn Commented Feb 15, 2012 at 3:13

3 Answers 3

1

change this :

$('ul.nav-scroll').css('height', height_css+'px');
Sign up to request clarification or add additional context in comments.

Comments

1

Your submit may be causing the page to reload due to the form being submitted, undoing your changes. If you don't want this to happen, add a return false to the end of your handler.

Comments

0

is this a typo? Your css definition has a "." in front of ul:

.ul.nav-scroll {     max-height: valueofinput+px }

your javascript selector does not correspond with the above:

$('ul.nav-scroll').css('max-height', height_css+'px'); 

Your css should be:

ul.nav-scroll {     max-height: valueofinput+px }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.