Is there a way in jquery
to strip out the <script>
tags that Ember.js generates?
<script id="metamorph-107-start" type="text/x-placeholder"></script>
<script id="metamorph-125-start" type="text/x-placeholder"></script>foo-bar-text<script id="metamorph-125-end" type="text/x-placeholder"></script>
<script id="metamorph-107-end" type="text/x-placeholder"></script>
I only want foo-bar-text
. Here is the selector I am currently using:
$(".control-group .controls .data").html();
Which returns the above.
Since the question is tagged with ember.js
and the text foo-bar-text
is inside a script metamorph tag, to avoid tose tag's you could define it in your templates like
{{unbound myProperty}}
this way you get the text only with your jQuery selector .html()
and don't need to strip out the script tag's.
"I only want foo-bar-text."
You could just use jQuery's text()
method then in that case:
$(".control-group .controls .data").text();
Or, using pure vanilla JavaScript:
document.querySelector('.control-group .controls .data').textContent;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.