javascript - Trouble adding horizontal scroll on dynamic table -
i'm trying following in javascript:
if (parseint($('#' + tablename + 'table').width()) > parseint($('#' + tablename + 'table').parent().width())) { console.log("here"); $('#' + tablename + 'table').css('overflow-x', 'scroll'); }
and it's logging console there no horizontal scroll bar...
change
$('#' + tablename + 'table').css('overflow-x', 'scroll');
to
$('#' + tablename + 'table').parent().css('overflow-x', 'scroll');
the parent element 1 needs overflow-x
property.
also don't need javascript functionality. can set overflow-x: auto;
parent element, , add scrollbar automatically if contents wide.
Comments
Post a Comment