top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How to change the value of a DIV using JavaScript?

0 votes
How to change the value of a DIV using JavaScript?
posted Feb 24, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

If you are using jquery just use

 $("your div id").text("your text");

Also don't forget to use the jquery library in your code as

<script src=""></script>
answer Feb 29, 2016 by Aman Mehrotra
0 votes

We use this very frequently

document.getElementById("<Your DIV ID>").innerHTML=<value of inner HTML>;

So in short you may need to use one of the following -

document.getElementById(id).innerHTML = new HTML
document.getElementById(id).attribute=new value
answer Feb 24, 2016 by Salil Agrawal
Similar Questions
0 votes

Write validation functions and modify the onSubmit event Handler in the form code to validate the following form fields:

  1. Phone Number
    • Must be entered
    • Must be below format
+3 votes

My form is somewhat like this:-

 <form id="form1" method="post" name="form1">
 //...fields like firstname, email......
 <button type="submit" id="submit" name="submit" onclick="validate(this)">SUBMIT</button>
 < /form>

The javascript validate function:-

function validate(ref)
            window.alert("First Name Cannot be Blank");

    // validating other fields like email... If any field is invalid return 

Now what the problem is suppose I left the firstname field blank and click submit button then windows alerts that firstname field is mandatory....and as soon as I click the OK button in alert form the form is posted...

Now question is that I assign the action attribute after validating all the fields and if any one is invalid the function returns in which case action attribute of the form is not assigned then how the form is submitted.
The form should have been submitted after all the validation tests will have been successful and controls would have reached document.form1.submit(). And what is the solution for this.

I am using Python Flask and rendering template using jinja2.

+1 vote

I want the javascript API which could capture the screen of the client. Does anyone knows about it?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.