javascript - Return Formatted Text Using html() or text() Methods -
i using clipboard.js plugin in order copy/paste text (code snippets) webpage. plugin works fine actually, paste text of element in same formatting displaying on website. there way such result? using html() or text() methods required text.
html
<input class="copy" type="button" value="copy" /> <pre class="snippet"> #wrapper { height: 100px; width: 100px; } #wrapper { height: 100px; width: 100px; } </pre> jquery
<script> $(document).ready(function(){ var clipboard = new clipboard('.copy', { text: function() { return $(".snippet").text(); } }); }); </script>
i have applied queryselector method, , solved issue, copied texts being paste formatting same see them on page.
$(document).ready(function(){ var clipboard = new clipboard('.copy', { target: function() { return document.queryselector('.snippet'); } }); });
Comments
Post a Comment