{"id":3574,"date":"2024-05-19T11:04:24","date_gmt":"2024-05-19T02:04:24","guid":{"rendered":"https:\/\/blue-bear.jp\/kb\/?p=3574"},"modified":"2024-05-19T11:04:26","modified_gmt":"2024-05-19T02:04:26","slug":"javascript-textarea%e3%81%ae%e7%b8%a6%e5%b9%85%e3%82%92%e8%87%aa%e5%8b%95%e3%81%a7%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blue-bear.jp\/kb\/javascript-textarea%e3%81%ae%e7%b8%a6%e5%b9%85%e3%82%92%e8%87%aa%e5%8b%95%e3%81%a7%e5%a4%89%e6%9b%b4%e3%81%99%e3%82%8b\/","title":{"rendered":"[javascript] textarea\u306e\u7e26\u5e45\u3092\u81ea\u52d5\u3067\u5909\u66f4\u3059\u308b"},"content":{"rendered":"\n<p>textarea\u306e\u7e26\u5e45\u3092\u81ea\u52d5\u3067\u5909\u66f4\u3059\u308b\u306b\u306f\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function fitTextareaHeight(textareaId) {\n  var textarea = document.getElementById(textareaId);\n  textarea.style.height = 'auto'; \/\/ Reset height to auto to calculate new height\n  textarea.style.height = textarea.scrollHeight + 'px'; \/\/ Set height to scroll height\n}\n\n\/\/ Example usage:\n\/\/ Assuming you have a textarea with id=\"myTextarea\"\n\/\/ You can call the fitTextareaHeight function whenever the textarea content changes\ndocument.getElementById('myTextarea').addEventListener('input', function() {\n  fitTextareaHeight('myTextarea');\n});\n\n\/\/ Call it initially to set the initial height\nfitTextareaHeight('myTextarea');<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>textarea\u306e\u7e26\u5e45\u3092\u81ea\u52d5\u3067\u5909\u66f4\u3059\u308b\u306b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3574"}],"collection":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/comments?post=3574"}],"version-history":[{"count":1,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3574\/revisions"}],"predecessor-version":[{"id":3575,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/posts\/3574\/revisions\/3575"}],"wp:attachment":[{"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/media?parent=3574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/categories?post=3574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blue-bear.jp\/kb\/wp-json\/wp\/v2\/tags?post=3574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}