Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Change an HTML <p> tag value to an empty value using JavaScript

I want to replace a content in a p tag by an empty value(" ")(in case there was a value entered by the user in this p tag) when i check a checkbox in javascript.

Html /javascript:

$('.checkboxesmodel1').change(function() {
  var option2and1_model1 = $("#option2and1_model1");
  var divall = document.querySelector('.options');
  if (($('#id_model1_option2').prop('checked')) && ($('#id_model1_option1').prop('checked'))) {
    option2and1_model1.hide();
    divall.querySelector('p').innerText = '';
  } else if (($('#id_model1_option2').prop('checked'))) {
    option2and1_model1.show();
  } else if (($('#id_model1_option1').prop('checked'))) {
    option2and1_model1.hide();
    divall.querySelector('p').innerText = '';
  } else {
    option2and1_model1.hide();
    divall.querySelector('p').innerText = '';
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
#Div Code of the checkboxes
<div id="tblmodel1options">
  <label for="id_model1_option1">
        <img  id="tinypic_2"
          src="{% static 'img/MODEL1OPTION 1.png' %}"/>
        <div class="checkboxesmodel1" >
          <input name = "model1_option1" id="id_model1_option1" type="checkbox"     autocomplete="off" />   
        </div>
      </label>

  <label for="id_model1_option2">
        <img id="tinypic_3"
          src="{% static 'img/MODEL1OPTION 2.png' %}" />
        <div  class="checkboxesmodel1" >
          <input name = "model1_option2" type="checkbox" id="id_model1_option2" autocomplete="off" />    
        </div>
      </label>
</div>
#Div Code of the form fields
<div id="option2and1_model1" class="options">
  <p id="id_c"><strong>c:</strong>{{ form.c}} mm</p>
  <p id="id_h"><strong>h:</strong>{{ form.h}} mm</p>
</div>

----->THos code javascript doesn't give me any result

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!