Previous Next

Interview Questions on Java Script

1. What is Java script?

Java Script is a programming language that is used to create interactive effects within web browsers.

2. How to write java script in html page?

By using  

3. Where can we write javascript code in HTML?

Any where. Whithin body or div or head.

4. How to link externally the javascript file?

syntax:-
<script type="text/javascript" src="external_javascript.js"></script>
Ex:-
<script type="text/javascript" src="validator.js"></script>

5. Write java script code to popup alertbox?

Bay using alert();
Ex:- alert(‘alert text goes here’);

6. How to write content to the console?

By using console.log();
Ex:- console.log(‘write text here’);

7. How to write content to the fresh document?

By using document.write();
Ex:- document.write(‘write content here’);

8. How to change the styles of html element in javascript?

Syntax :- document.getElementById(‘idname’).style.propertynname=’value’;
Ex : - document.getElementById(‘container).style.color=red; 

9. How to get content of particular div element?

By using innerHTML property
Ex:- var1 = document.getElementById(‘#container’).innerHTML;

10. How to change the content of particular div element?

document.getElementById(‘#idname).innerHTML = ‘html code goes here’ ;

Previous Next