jQuery を使用して、ユーザーが小さなデバイス (~320px 以下) を使用している場合、プレースホルダー テキストをテキストエリアに変更するにはどうすればよいですか? 小さな画面の場合は「返信...」に変更したいのですが、320pxを超えると「[名前]に返信...」に戻ります
現在、私のHTML:
<textarea class="my_textarea" rows="1" type="text" placeholder="Reply to Joe..."></textarea>
<textarea class="my_textarea" rows="1" type="text" placeholder="Reply to Jane..."></textarea>
jQuery:
function changePlaceholder() {
if( $(window).width() < 320 ){
$('.my_textarea').attr('placeholder','Reply...');
} else {
// how do I change it back here if there are many textarea's on the page?
}
}
// initiate first
changePlaceholder();
// resize
$(window).resize( changePlaceholder );
元のプレースホルダーに戻すにはどうすればよいですか?