Disy Posted October 18, 2019 Report Share Posted October 18, 2019 Хочу сделать показ/срытие (замена друг друга) двух элементов, а то есть кнопку отправки личного сообщения в диалоге (сделать как у вк), когда нету в textarea текста вместо кнопки отправить стоит кнопка записать голосовое сообщение, а если в textarea есть (или появляется текст) то данная кнопка меняется и т д.. имеется такой код: <script> var textarea = document.getElementById('msg_text'); var span1 = document.getElementById('golosim'); textarea.addEventListener('keypress', function() { span1.style.display = "none"; }); var textarea = document.getElementById('msg_text'); var span = document.getElementById('sending'); textarea.addEventListener('keypress', function() { span.style.display = "block"; }); </script> <textarea class="videos_input wysiwyg_inpt fl_l im_msg_texta" onkeypress="showdiv()" id="msg_text" placeholder="{translate=lang_369}"></textarea> <span1 class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span1> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> и как бы все работает, но когда поле очищаешь то замена обратно не происходит, весь инет обкопал что нужно в js вставить, так и не нашел, может вы знаете??? PS: выше скрипт тестовый (строго не судите) =)) Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 как бы мне по факту нужен либо код более нормальный (другой), либо антоним значению keypress Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 Убери это всё. $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 (edited) От души Edited October 18, 2019 by Disy Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 (edited) 4 минуты назад, Disy сказал: 1 час назад, Mario сказал: Убери это всё. $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); <script> $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); </script> <span class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> Сделал так и не работает..( Edited October 18, 2019 by Disy Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 7 минут назад, Disy сказал: <script> $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); </script> <span class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> Сделал так и не работает..( Оберни что бы оно при полной загрузке страницы включалось. $(function(){ $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); }); Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 2 минуты назад, Mario сказал: Оберни что бы оно при полной загрузке страницы включалось. $(function(){ $('#msg_text').change(function(r){ if($(r).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); }); скрипт обернул и все равно не меняется, может тут ошибся где нибудь: <span class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 26 минут назад, Disy сказал: скрипт обернул и все равно не меняется, может тут ошибся где нибудь: <span class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> Нет, может какие-то ошибки в жс есть и оно стопорит торможение этого Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 8 минут назад, Mario сказал: Нет, может какие-то ошибки в жс есть и оно стопорит торможение этого Специально отключил все скрипты и оставил этот единственный, все же не пашет.. Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 9 минут назад, Disy сказал: Специально отключил все скрипты и оставил этот единственный, все же не пашет.. Дай ссылку на сайт, где он стоит Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 1 минуту назад, Mario сказал: Дай ссылку на сайт, где он стоит https://wordgram.ru Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 Там только русские номера телефонов можно подтвердить Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 Скрипт не подключен на страницу сообщений, да и ошибки функций есть (других) Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 2 минуты назад, Mario сказал: Скрипт не подключен на страницу сообщений, да и ошибки функций есть (других) я этот скрипт не в profile засунул а просто в теги <script></script> на странице той, а ошибки другие они не значительные и не влияют, может все же надо в profile подключить его??? Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 21 минуту назад, Disy сказал: я этот скрипт не в profile засунул а просто в теги <script></script> на странице той, а ошибки другие они не значительные и не влияют, может все же надо в profile подключить его??? Его нет ни в profile.js (и не надо), ни в странице сообщений Quote Link to comment Share on other sites More sharing options...
Disy Posted October 18, 2019 Author Report Share Posted October 18, 2019 42 минуты назад, Mario сказал: Его нет ни в profile.js (и не надо), ни в странице сообщений Вот щас вытащил, в коде скрипт есть но все равно не ошибку не выдает и не грузит.. Quote Link to comment Share on other sites More sharing options...
Mario Posted October 18, 2019 Report Share Posted October 18, 2019 5 часов назад, Disy сказал: Вот щас вытащил, в коде скрипт есть но все равно не ошибку не выдает и не грузит.. $('#msg_text').bind('input',function(){ if($(this).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); Quote Link to comment Share on other sites More sharing options...
Disy Posted October 19, 2019 Author Report Share Posted October 19, 2019 Кто может все же подсказать как правильно сделать? Вот такой код имеется, но и с ним не работает: </script> $(function(){ $('#msg_text').bind('input',function(){ if($(this).val()){ $('#sending').show(); $('#golosim').hide(); } else { $('#sending').hide(); $('#golosim').show(); } }); }); </script> <span class="but_golos_im" style="display: block;" onClick="Recording.toogle(this);" id="golosim" onselectstart="return false"></span> <span class="but_mess_im" style="display: none;" onClick="im.send('{for_user_id}', '{my-name}', '{my-ava}')" id="sending" onselectstart="return false"></span> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.