How to delete a string before an html? [duplicate]










0
















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










share|improve this question















marked as duplicate by Mamun javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

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 '18 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.






















    0
















    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










    share|improve this question















    marked as duplicate by Mamun javascript
    Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

    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 '18 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.




















      0












      0








      0









      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










      share|improve this question

















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 11 '18 at 13:37







      rob.m

















      asked Nov 11 '18 at 13:31









      rob.mrob.m

      3,729113983




      3,729113983




      marked as duplicate by Mamun javascript
      Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

      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 '18 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 javascript
      Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

      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 '18 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.
























          3 Answers
          3






          active

          oldest

          votes


















          2














          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.






          share|improve this answer























          • Ok thanks, this works

            – rob.m
            Nov 11 '18 at 13:40


















          0














          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();





          share|improve this answer























          • if I could I would but I can't therefore i won't!

            – rob.m
            Nov 11 '18 at 13:46












          • Don't change the condition, according to what you know and answer as asked.

            – NAVIN
            Nov 11 '18 at 16:29


















          -1














          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>








          share|improve this answer























          • 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 '18 at 13:36






          • 1





            The text is not wrapped in paragraphs.

            – Minder Mondo
            Nov 11 '18 at 13:36

















          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          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.






          share|improve this answer























          • Ok thanks, this works

            – rob.m
            Nov 11 '18 at 13:40















          2














          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.






          share|improve this answer























          • Ok thanks, this works

            – rob.m
            Nov 11 '18 at 13:40













          2












          2








          2







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 '18 at 13:37









          Minder MondoMinder Mondo

          1336




          1336












          • Ok thanks, this works

            – rob.m
            Nov 11 '18 at 13:40

















          • Ok thanks, this works

            – rob.m
            Nov 11 '18 at 13:40
















          Ok thanks, this works

          – rob.m
          Nov 11 '18 at 13:40





          Ok thanks, this works

          – rob.m
          Nov 11 '18 at 13:40













          0














          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();





          share|improve this answer























          • if I could I would but I can't therefore i won't!

            – rob.m
            Nov 11 '18 at 13:46












          • Don't change the condition, according to what you know and answer as asked.

            – NAVIN
            Nov 11 '18 at 16:29















          0














          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();





          share|improve this answer























          • if I could I would but I can't therefore i won't!

            – rob.m
            Nov 11 '18 at 13:46












          • Don't change the condition, according to what you know and answer as asked.

            – NAVIN
            Nov 11 '18 at 16:29













          0












          0








          0







          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();





          share|improve this answer













          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();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 '18 at 13:44









          thecoolwinterthecoolwinter

          187




          187












          • if I could I would but I can't therefore i won't!

            – rob.m
            Nov 11 '18 at 13:46












          • Don't change the condition, according to what you know and answer as asked.

            – NAVIN
            Nov 11 '18 at 16:29

















          • if I could I would but I can't therefore i won't!

            – rob.m
            Nov 11 '18 at 13:46












          • Don't change the condition, according to what you know and answer as asked.

            – NAVIN
            Nov 11 '18 at 16:29
















          if I could I would but I can't therefore i won't!

          – rob.m
          Nov 11 '18 at 13:46






          if I could I would but I can't therefore i won't!

          – rob.m
          Nov 11 '18 at 13:46














          Don't change the condition, according to what you know and answer as asked.

          – NAVIN
          Nov 11 '18 at 16:29





          Don't change the condition, according to what you know and answer as asked.

          – NAVIN
          Nov 11 '18 at 16:29











          -1














          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>








          share|improve this answer























          • 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 '18 at 13:36






          • 1





            The text is not wrapped in paragraphs.

            – Minder Mondo
            Nov 11 '18 at 13:36















          -1














          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>








          share|improve this answer























          • 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 '18 at 13:36






          • 1





            The text is not wrapped in paragraphs.

            – Minder Mondo
            Nov 11 '18 at 13:36













          -1












          -1








          -1







          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>








          share|improve this answer













          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>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 11 '18 at 13:35









          shaghayegh sheykholeslamishaghayegh sheykholeslami

          1887




          1887












          • 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 '18 at 13:36






          • 1





            The text is not wrapped in paragraphs.

            – Minder Mondo
            Nov 11 '18 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 '18 at 13:36






          • 1





            The text is not wrapped in paragraphs.

            – Minder Mondo
            Nov 11 '18 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 '18 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 '18 at 13:36




          1




          1





          The text is not wrapped in paragraphs.

          – Minder Mondo
          Nov 11 '18 at 13:36





          The text is not wrapped in paragraphs.

          – Minder Mondo
          Nov 11 '18 at 13:36



          Popular posts from this blog

          𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

          Edmonton

          Crossroads (UK TV series)