I have two data attribute and i want to grab the value of the data-attribute.
<div class="message" data-error-message="password reset <p><b>The e-mail address you entered does not exist.</b><br></p>
<p>Check if you entered email correctly or <a href=www.gmail.com target="target">create a new account</a>.</p></div>
<div data-error-message="email You can’t leave this field empty!"></div>
Output should be = password reset The e-mail address you entered does not exist , email You can’t leave this field empty.
var msg = jQuery('[data-error-message]').map(function() {
return jQuery(this).data('error-message').replace(/<[^>]+>/g, '').replace(/(\r\n|\n|\r)/gm,"").replace(" ","").trim().split('.').join(' ');
}).get();
var msg = msg.join(',')
console.log(msg)