I looked around stackoverflow but I couldn't find an answer that solved my problem. I hope I can explain it so you all understand what I'm trying to do... (If more info is needed, please let me know).
I have a piece PHP script that adds and removes content from an session array. Right now this is the code for this script:
<?php foreach ($_SESSION['products'] as $product): ?>
<p style="font-size:1.2rem"><?php echo htmlspecialchars($product); ?></p>
<?php endforeach;?>
Using Javascript I echo this to a textarea
where it returns the values.
Javascript
$('.my-subject').click(function(){
var title = $(this).attr('value');
$("textarea#thema").html(data);
})
Right now it returns the value with the HTML Tags <p>
...</p>
.
How can I get it to return the value's with no HTML tags and a line break at the end? I tried using:
$("textarea#thema").text() + '
';
But that didn't work, this still shows the <p>
-tags and no line break.
I also saw some codes like this:
function removeTags(){
var txt = document.getElementById('myString').value;
var rex = /(<([^>]+)>)/ig;
alert(txt.replace(rex , ""));
}
But I don't know if I can use that for my code and how to do this... Any help would be appreciated. Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…