How to delete a string before an html? [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
Jquery - Remove only text content from a div
6 answers
I have
<div class="col-xs-12">
Congratulations! Here is your submitted post.
<p class="post-details">Lorem ipsum</p>
</div>
How can i remove Congratulations! Here is your submitted post.
?
I tried few things like:
$(".post-details").each(function(){
var text = $(".post-details").prev().text().remove();
console.log(text);
});
But it doesn't catch that text.
Also tried this answer but it doesn't work https://stackoverflow.com/a/1571096/1018804
javascript jquery
marked as duplicate by Mamun
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
Jquery - Remove only text content from a div
6 answers
I have
<div class="col-xs-12">
Congratulations! Here is your submitted post.
<p class="post-details">Lorem ipsum</p>
</div>
How can i remove Congratulations! Here is your submitted post.
?
I tried few things like:
$(".post-details").each(function(){
var text = $(".post-details").prev().text().remove();
console.log(text);
});
But it doesn't catch that text.
Also tried this answer but it doesn't work https://stackoverflow.com/a/1571096/1018804
javascript jquery
marked as duplicate by Mamun
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
Jquery - Remove only text content from a div
6 answers
I have
<div class="col-xs-12">
Congratulations! Here is your submitted post.
<p class="post-details">Lorem ipsum</p>
</div>
How can i remove Congratulations! Here is your submitted post.
?
I tried few things like:
$(".post-details").each(function(){
var text = $(".post-details").prev().text().remove();
console.log(text);
});
But it doesn't catch that text.
Also tried this answer but it doesn't work https://stackoverflow.com/a/1571096/1018804
javascript jquery
This question already has an answer here:
Jquery - Remove only text content from a div
6 answers
I have
<div class="col-xs-12">
Congratulations! Here is your submitted post.
<p class="post-details">Lorem ipsum</p>
</div>
How can i remove Congratulations! Here is your submitted post.
?
I tried few things like:
$(".post-details").each(function(){
var text = $(".post-details").prev().text().remove();
console.log(text);
});
But it doesn't catch that text.
Also tried this answer but it doesn't work https://stackoverflow.com/a/1571096/1018804
This question already has an answer here:
Jquery - Remove only text content from a div
6 answers
javascript jquery
javascript jquery
edited Nov 11 at 13:37
asked Nov 11 at 13:31
rob.m
3,629103782
3,629103782
marked as duplicate by Mamun
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Mamun
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 11 at 13:41
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
Check this:
https://stackoverflow.com/a/17852238/5089697
It filters the content inside any element and find the correct node you want to remove (in your case the text which is not wrapped in any element but it is a child to the div). Try it.
Ok thanks, this works
– rob.m
Nov 11 at 13:40
add a comment |
up vote
0
down vote
You could put the text you want to delete inside a div element with an id and remove that div.
Like this:
<div class="col-xs-12">
<div id=“textToRemove”>Congratulations! Here is your submitted post.</div>
<p class="post-details">Lorem ipsum</p>
</div>
Then remove the div with jquery like so:
$("#textToRemove").remove();
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
add a comment |
up vote
-1
down vote
here are what you want.
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Check this:
https://stackoverflow.com/a/17852238/5089697
It filters the content inside any element and find the correct node you want to remove (in your case the text which is not wrapped in any element but it is a child to the div). Try it.
Ok thanks, this works
– rob.m
Nov 11 at 13:40
add a comment |
up vote
2
down vote
accepted
Check this:
https://stackoverflow.com/a/17852238/5089697
It filters the content inside any element and find the correct node you want to remove (in your case the text which is not wrapped in any element but it is a child to the div). Try it.
Ok thanks, this works
– rob.m
Nov 11 at 13:40
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Check this:
https://stackoverflow.com/a/17852238/5089697
It filters the content inside any element and find the correct node you want to remove (in your case the text which is not wrapped in any element but it is a child to the div). Try it.
Check this:
https://stackoverflow.com/a/17852238/5089697
It filters the content inside any element and find the correct node you want to remove (in your case the text which is not wrapped in any element but it is a child to the div). Try it.
answered Nov 11 at 13:37
Minder Mondo
1336
1336
Ok thanks, this works
– rob.m
Nov 11 at 13:40
add a comment |
Ok thanks, this works
– rob.m
Nov 11 at 13:40
Ok thanks, this works
– rob.m
Nov 11 at 13:40
Ok thanks, this works
– rob.m
Nov 11 at 13:40
add a comment |
up vote
0
down vote
You could put the text you want to delete inside a div element with an id and remove that div.
Like this:
<div class="col-xs-12">
<div id=“textToRemove”>Congratulations! Here is your submitted post.</div>
<p class="post-details">Lorem ipsum</p>
</div>
Then remove the div with jquery like so:
$("#textToRemove").remove();
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
add a comment |
up vote
0
down vote
You could put the text you want to delete inside a div element with an id and remove that div.
Like this:
<div class="col-xs-12">
<div id=“textToRemove”>Congratulations! Here is your submitted post.</div>
<p class="post-details">Lorem ipsum</p>
</div>
Then remove the div with jquery like so:
$("#textToRemove").remove();
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
add a comment |
up vote
0
down vote
up vote
0
down vote
You could put the text you want to delete inside a div element with an id and remove that div.
Like this:
<div class="col-xs-12">
<div id=“textToRemove”>Congratulations! Here is your submitted post.</div>
<p class="post-details">Lorem ipsum</p>
</div>
Then remove the div with jquery like so:
$("#textToRemove").remove();
You could put the text you want to delete inside a div element with an id and remove that div.
Like this:
<div class="col-xs-12">
<div id=“textToRemove”>Congratulations! Here is your submitted post.</div>
<p class="post-details">Lorem ipsum</p>
</div>
Then remove the div with jquery like so:
$("#textToRemove").remove();
answered Nov 11 at 13:44
thecoolwinter
85
85
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
add a comment |
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
if I could I would but I can't therefore i won't!
– rob.m
Nov 11 at 13:46
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
Don't change the condition, according to what you know and answer as asked.
– NAVIN
Nov 11 at 16:29
add a comment |
up vote
-1
down vote
here are what you want.
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
add a comment |
up vote
-1
down vote
here are what you want.
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
add a comment |
up vote
-1
down vote
up vote
-1
down vote
here are what you want.
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
here are what you want.
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
function Delete(){
$('#con').text('');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-xs-12">
<p id='con'>
Congratulations! Here is your submitted post.
</p>
<p class post-details>Lorem ipsum</p>
</div>
<button onclick='Delete()'>Delete</button>
answered Nov 11 at 13:35
shaghayegh sheykholeslami
1837
1837
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
add a comment |
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
well yea but I don't have an id or any container in the text as you can see per the question
– rob.m
Nov 11 at 13:36
1
1
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
The text is not wrapped in paragraphs.
– Minder Mondo
Nov 11 at 13:36
add a comment |