javascript - How to get the object reference of a HTML element for jQuery use? -


a div container open nicely fit overflow content. works. how connect reference of triggered html element jquery. there should better way $("#"+divid)

i got code:

$('.text').mouseenter(function() {  //var $id = $(this); ? //var $id = document.getelementbyid(divid); ? var divid = this.id;     var $id = $("#"+divid);  var overflow = $id.prop("scrollheight");  this.divheight = $id.height();  $id.animate({height:overflow},1000); });  .text{ color: #000000; background-color: #ffffff; overflow: hidden; height: 100px; position: relativ;}   <div  class="text" id="text1"> <content> </div> <div  class="text" id="text2"> <content> </div> <div  class="text" id="text3"> <content> </div> 

ps why $(this).height() working not $(this).prop("scrollheight") ?

thanks understanding.

try this

change this

var divid = this.id; var $id = $("#"+divid); 

to

var $id = $(this); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -