I have a text string like this:
Aliquam sit amet *scelerisque hate*, at ullamcorper fair. Phasellus at sem ultricies, gravida lorem id, faucibus tellus.
What I want is that the sentence that is enclosed in asterisks becomes strong. I've tried this, but it doesn't work:
var value = $('.articulo').val();
var regex = /\*([a-zA-Z\d\w\s]+)\*/gi
$(".articulo").html(value.replace(regex, "<strong>$1</strong>"));
I appreciate your responses and comments.
This happens because text elements, let's say an html "p" tag don't have the "value" property, to get the content of a "p" element inside the DOM you have to use the $('. article').html() or $('.article').text();
The code would be as follows: