jquery - How to add Google translate box (single word/sentence, not whole page) to website? -
how add google translate box (single word/sentence, not whole page) website https://translate.google.com/
i got solution. not exact google providing. please improve answer if have better solution.
<div class="translate"> <form method="post"> <input type="text" name="input_element" id="target" placeholder="type germen word"> </form> <br> <div class="inpt-el"></div><br> <div class="translate_control" lang="de"></div> </div> <script> function googlesectionalelementinit() { new google.translate.sectionalelement({ sectionalnodeclassname: 'translate', controlnodeclassname: 'translate_control', background: '#f4fa58' }, 'google_sectional_element'); } </script> <script src="//translate.google.com/translate_a/element.js?cb=googlesectionalelementinit&ug=section&hl=en"></script> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script> $( "#target" ).keyup(function() { $('.inpt-el').text($(this).val()); }); </script>
Comments
Post a Comment