Salman
Salman

Reputation: 1024

Increase width from 0 to a 100% with css or jquery

i want to increase my width from 0 to a 100.

I've tried this:

            <script type="text/javascript">
    $(document).ready(function(){
        $("#underline").animate({width: '250px'});
    };
    </script>

To make it increase it's width but it won't work. I've also done some research too see if it's possible with css, but i keep ending up with tutorials on hover effects.

I would really appreciate if someone could help me with the problem.

Upvotes: 0

Views: 183

Answers (3)

Naga Sai A
Naga Sai A

Reputation: 10975

Syntax error: Closing bracket missing for document.ready

JS:

   $(document).ready(function(){
        $("#underline").animate({width: '250px'});
    });

http://codepen.io/nagasai/pen/rLqqZE

Upvotes: 2

bipen
bipen

Reputation: 36541

Your script looks good. Just that, I think you are missing a parenthesis there which is breaking your code. :)

<script type="text/javascript">
$(document).ready(function(){
    $("#underline").animate({width: '250px'});
 });
//^------- here
</script>

Upvotes: 2

JPeG
JPeG

Reputation: 821

You want this:

 $(document).ready(function(){
        $("#underline").css('width', '250px');
    });

Working fiddle here:

https://jsfiddle.net/hbtv3bkn/

Upvotes: 1

Related Questions