1

solved with @jcubic code: "To get the value use $("#expand"+idxpand).css('overflow');"


I want to get the property of overflow.
   alert(document.getElementById("expand"+idxpand).style.overflow);

Onclick if div overflow is set to hidden, expand the content . If is not set to hidden, set to overflow:hidde.

 $('<div id="expand'+xpndid+'" style="position: relative;overflow-y: hidden;
max-height: 255px;"></div><a href="#" onclick="idxpand='+xpndid+';
expandimg();" >view photo</a>').prependTo('#mybox').hide().fadeIn('slow');
xpndid++; 
function expandimg(){
if (document.getElementById("expand"+idxpand).style.overflow == 'hidden')
    {
    //do things}
 else{
//set to hidden
}
}

I am unable to get the property. On alert I get empty value. Any idea?

CCA
  • 39
  • 7
  • probably ther style is applied through a stylesheet and is not added on the element's style property, use this http://stackoverflow.com/a/2953122/3591273 – Nikos M. May 02 '15 at 12:23
  • Maybe because you use an ' in your id. Thought you have to Note it like \' – Thomas Pereira May 02 '15 at 12:28
  • 1
    Try to use jQuery `$("#expand"+idxpand).css('overflow', 'hidden')` – jcubic May 02 '15 at 12:30
  • @jcubic I want to get the property, not to set. @ Nikos for alert(css(document.getElementById("expand0"))); in console log I get this error :Uncaught ReferenceError: css is not defined – CCA May 02 '15 at 12:46
  • To get the value use `$("#expand"+idxpand).css('overflow');` – jcubic May 02 '15 at 12:47

1 Answers1

1

I think that you get the wrong element, try:

<a href="#" onclick="idxpand='\'+xpndid+\'';expandimg();" >view photo</a>
jcubic
  • 61,973
  • 54
  • 229
  • 402