I've spent some time trying to figure out a solution that would copy a multi-line list in HTML, remove tags and indentions all from a button onclick without using Flash. In my research I have run across "jQuery click button copy to clipboard" and I have tested Alvaro Montoro's answer but the solution doesn't work on a multi-line list but it works great for paragraph text. I do not intend to support Clipbaord API because it shows very limited support across browsers. Researching further I ran across "HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?" and Thayne's answer links to a blog post but it will copy all the HTML. I have figured out how to strip the tags and indents:
HTML:
<button onclick="copyToClipboard('#therecipe')">Copy List</button>
<div class="listing">
<ul id="someList">
<li>1 million</li>
<li>Monday</li>
<li>Something</li>
<li>Foobar</li>
<li>1tsp blah</li>
</ul>
</div>
<textarea class="auto"></textarea>
jQuery:
$('button').click(function(element) {
var thelist = $('#someList').html();
thelist = thelist.replace(/\s+<li>/g, '');
thelist = thelist.replace(/<\/?li>/g, '\r');
$('.auto').val(thelist);
});
How can I copy a multi-line list item with jQuery, remove tags, remove indentions, and copy to a clipboard without using Flash? Is there a plugin that supports all the latest browsers I am not seeing?