Hello. Please tell me how to correctly modify this script so that when the screen resolution is less than 420px, the height of the detail_text block changes the value? Now, at any screen resolution, the value is set to 200px, which is not suitable for mobile phones. Dug in the direction of matchMedia, but something goes wrong.
<script type="text/javascript"> var element_detail_text = $("#detail_text").html(); $("#detail_text_resize").show(); function resize_text_field(){ if(document.getElementById("detail_text").offsetHeight > 200){ document.getElementById("detail_text").style.overflow = "hidden"; document.getElementById("detail_text").style.height = "200px"; document.getElementById("detail_text_resize").style.display = ""; } resize_text_field(); onload = function(){ resize_text_field() } function element_detail_show(){ $("#detail_text_resize").hide(); document.getElementById('detail_text').style.overflow=''; document.getElementById('detail_text').style.height='auto'; $("#detail_text_minimize").show(); } function element_detail_hide(){ $("#detail_text_minimize").hide(); document.getElementById('detail_text').style.height='200px'; document.getElementById('detail_text_resize').style.display='inline-block'; document.getElementById('detail_text').style.overflow='hidden'; $("#detail_text_resize").show(); } </script>