.
Previous Next

Interview Questions on JQuery

11. How to get value of input box?

$('#id’).val();
Ex :- var bla = $('#tinput_id1’).val();

12. How to declare and initialize variables?

Var varname = value
Ex:- var var1=5;

13. How to concat two strings in jQuery?

Use +
Ex 1:- var string = “string1”+”string2”;
Ex :- var str1=”string1”;
Var str2 =”string2”;
Var string3=  str1+str2;

14. How to write comments in jQuery?

Method 1 : //commentd goes here
Method 2 :- /* comments goes here */

15. How to convert string to number?

Use parseInt(stringvalue);
Ex:- var var1= parseInt(‘3’);

16. How to convert number to string?

Use toString() method.

17. How to create an array in jQuery?

Just like in javasctipt.
Var arrayname=[value1,value2,calue3];
Ex :- var array1=[3,6,8];

18. What is function?

Def :- Set of statements to perform a particular operation.
Syntax :- 
function function_name(arg1,arg2){
//body
}
Ex :- 
function myFunction(p1, p2) {
    return p1 * p2;   
    // The function returns the product of p1 and p2
}

19. Can we access local variable out side the function?

No. they are permitted to that function only.

20. How to create global variables?

Create variables outside function.

Previous Next