Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change height of div on click with jquery

I'm trying to expand the height of a div element with the following code:

html:

<div id="expandbtn">more..</div>

<div id="portfolio"><div class="itemweb" title="lol" rel="#derp"><div class="thumb"><img src="images/items/skills.jpg" title="Skills" rel="#derp"/></div>

script:

$('#expandbtn').click(function(){
$('#portfolio').animate({height:'72px'}, 500);});

css:

#portfolio {
width:914px;
height:295px;
margin:0 0 0 -8px;
overflow:hidden;}

But it won't work. What am i doing wrong?

like image 367
Biels Avatar asked Dec 05 '11 17:12

Biels


2 Answers

your code is just fine. you can also try

$('#portfolio').css("height","74px");

try putting some backgroung color or image to visualize clearly

fiddle : http://jsfiddle.net/49HQM/4/

like image 185
dku.rajkumar Avatar answered Oct 12 '22 19:10

dku.rajkumar


Try toload it when the document is ready:

  $(document).ready(function(){
      $('#expandbtn').click(function(){
      $('#portfolio').animate({height:'72px'}, 500);
   });
like image 25
user3470042 Avatar answered Oct 12 '22 19:10

user3470042