I am using ZeroClipboard to copy code from a generator which can then be pasted by the user. I can easily copy the code from the generator to the clipboard, however when I add the .replace
command after .innerHTML
it also copies the html tags <p>
and <span>
.
The HTML for the output of the generator is as shown below:
<div id="jj_yourcode_br" class="jj_yourcode">
<p>border-radius: <span id="jj_radius">10</span>px; </p>
</div>
and the javascript that gets the text from the element and tried to replace the HTML tags with a blank value.
<script type="text/javascript">
ZeroClipboard.setMoviePath( 'http://joomjunk.co.uk/modules/mod_css3_gen/js/ZeroClipboard.swf' );
var clip = new ZeroClipboard.Client();
clip.setText( document.getElementById('jj_yourcode_br').innerHTML.replace(/<\S[^><]*>/g, '' );
clip.glue( 'd_clip_button' );
</script>
What have I done wrong with the javascript code and how can I fix it so that it eliminates these tags?
you are missing a )
there
clip.setText(document.getElementById('jj_yourcode_br').innerHTML.replace(/<\S[^><]*>/g, '' ));