Reputation: 3433
I am having a contenteditable div. So according to a very good post here html tags are added on enter key press for different browsers. Now i want to replace these with a new line character and send it to imagemagick plugin to create a new line effect. HOw can i do this with jquery on the client side.
I am trying to do this but not getting the result:
messageText1 = $("#templateIframe")
.contents()
.find("#dialog")
.html()
.replace(/<(?:.|)*?>/gm, '\\n')
.replace(/ /g, '');
alert(messageText1);
messageText = messageText1.replace(/\n{2}/g, '\\n');
alert(messageText1);
Upvotes: 0
Views: 1361
Reputation: 3433
Got the solution from this post
messageText = $("#templateIframe")
.contents()
.find("#dialog")
.html()
.replace(/<(?:.|)*?>/gm, '\\n')
.replace(/ /g, '')
.replace(/\\n\\n/g,"\\n");
alert(messageText);
Upvotes: 1