Reputation: 10030
<script type="text/javascript">
$(document).ready( function() {
$(".editableContent").bind('paste', function() {
var value = $(this).text();
var string = value.replace(/(<([^>]+)>)/ig,"");
$(this).text(string);
});
});
</script>
Paste Function Does not work for first time but second time it works , why?
Upvotes: 1
Views: 879
Reputation:
Looks like you're trying to remove markup from your editable div. Just use this:
$(".editableContent").on('paste', function() {
var self = this;
setTimeout(function() {
$(self).find('*').remove();
$(self).append('<br />')
}, 0);
});
Here is a demonstration: http://jsfiddle.net/4jSNN/1/
Upvotes: 1