Javascript Tutorial


Learn everything about basic and advance javascript...


45 User See All
NAGA SAI HEMANTH JAMILIVishal PatelChirag MalaviyaAnsari Md TahirKetan Chaudhari
Jigar ParikhAbhishek PatelBhavesh PrajapatiHiren DarjiDhaval Kakadiya
Ashish MishraTushar PrajapatiShashvat ParekhHumbal NehaPratik Gandhi
Pratik PatelNirmal ShahMask JakashKalpesh PrajapatiPratik Mistry
Hemal PatelEr Chandresh PrajapatiDarshan PatelHinal ShahPatel Nikhil
Tahir PatelDhruvin ShahKalpesh BhadraShaily ShahDevarshi Gandhi
Rabari NirmalKishan SonaniVishal ThakkarKonik PokarSohil Kureshi
Rajesh PansaraShah JigneshMoni KachhadiyaSagar LodhiyaVatan Bhagat
Nirav GamitArpan PatelVivek BarotRinkal PatelJoydip Panchal
Photo
Back to cluster list

Make Comments..!!


Joydip Panchal
Disable right-click contextual menu

$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
Like · Comment ·
Joydip Panchal
Send form data via ajax jQuery :

Do you want to submit form via ajax? Do you want to upload files via ajax? Refer following code :

var formObj = $("#your-form-id";
var formData = new FormData(formObj[0]);
$.ajax({
url: formObj.attr("action", //server script to process data
type: formObj.attr("method", // method for sending data
dataType: 'json', // return type of response data from above url
data: formData,
cache: false,
success: function (response)
{
// this will call after request successfully done
},
error: function () {
// this will call if request has any error
},
contentType: false,
processData: false
});
Like · Comment ·
Admin likes this
Joydip Panchal
Add event.preventDefault(); return false; this after ajax call, this will stop actual redirection of page
Like · 1 ·
Admin
Good
Like ·
Joydip Panchal
http://davidwalsh.name/webgl-demo
Like · Comment ·
Ansari Md Tahir likes this
Joydip Panchal
How to get value from textbox in javascript?

Example :

<html>
<head>
<script type="text/javascript">
function getValue()
{
var val = document.getElementById("textbox1".value;
alert(val);
}
</script>
</head>
<body>
<input type="text" id="textbox1" />
<button onClick="getValue()">Get Value</button>
</body>
</html>
Like · Comment ·
Ansari Md Tahir and 3 other like this
Er Krupa Patel
that's gud
Like · 4 ·
Jaydip Pithva
what good
Like ·
Ansari Md Tahir
3 ways we can get value in javascript..
Like ·
Joydip Panchal
How to access element using Class name attribute?

Syntax :

var element = document.getElementByClassName("test";

Here, element is the list of reference to all class which name is "test"....

You can run the for loop to get the value of all class..

Like,

for(i=0;i<element.length;i++)
// code for access element ... element[i]
Like · Comment ·
Sagar Solanki and Admin like this
Ravi Patel
hi
Like ·
Pratik Mistry
what is new in jquery
Like · Comment ·
Joydip Panchal
You can create a new object with use of 'new' keyword....
Like · 1 ·
Pratik Mistry
thnx
Like · 1 ·
Joydip Panchal
How to increment counter in javascript?

<html>
<head>
<script type="text/javascript">
var counter = 0;
function incCounter()
{
counter++;
document.getElementById("counter".innerHTML = counter;
}
</script>
</head>
<body>
<strong>Current Counter is : <span id="counter">0</span></strong>
<button onClick="incCounter()">Click Me</button>
</body>
</html>
Like · Comment ·
Ansari Md Tahir and 3 other like this
Joydip Panchal
What we can do with javascript??

-> Display messages to the user as part of a web page, in the browser's status line, or in alert boxes.

-> Validate the contents of a form and make calculations

-> Animate images or create image that change when you move the mouse over them

-> Create ad banners that interact with the user, rather than simply displaying a graphic

-> Detect the browser in use or its features and perform advanced functions only on browsers that support them

-> Modify all or part of a web page without requiring the user to reload it

-> Display or interact with data retrieved from a remote server
Like · Comment ·
Ankit Koshti and 3 other like this
Joydip Panchal
Note #1

While creating js code be sure that all the ids are declared on page which ids you are using on js file...
Like · Comment ·
Admin likes this
Joydip Panchal
How to declare a variable in javascript??

You can declare any type of variables with the var statement.

Example :

<html>
<body>

<script type='text/javascript'>

var x=34.5;
document.write(x + "<br>"

var x=34;
document.write(x + "<br>"

var x="Help2engg";
document.write(x + "<br>"

var x='h';
document.write(x + "<br>"
</script>

</body>
</html>

Here, you notice that same name can be used for storing different types of data like float,integer,string and char..
Like · Comment ·
Kaushal Mejadiya and Arpan Patel like this
Joydip Panchal
html - How to get div element values in javascript???

To get value from any Div element, first give it id and then access it by its id.

Example :
<html>
<head>
<script type='text/javascript'>
function showValue()
{
alert(document.getElementById('pText').innerHTML);
}
</script>
</head>
<body>
<p id='pText'>Help2engg</p>
<button onclick='showValue()'>Click Me</button>
</body>
</html>
Like · Comment ·
Admin and 2 other like this
Moni Kachhadiya
hey friend if any one have 7th IT papper of modasa engg college then plezz plezz upload as soon as possible(all papper))
Like ·
Joydip Panchal
Which is the best way to check your javascript working or not???

Put alert() function each step, you can easily find error..
Like · Comment ·
Admin and Moni Kachhadiya like this
Joydip Panchal
To include external js file into Web page you have use following syntax

<script type='text/javascript' src='filename.js'></script>

You can write it into head section or body section.
It's wise to write it just above the closing body tag so your page can load fast!!
Like · Comment ·
Pratik Patel likes this
Joydip Panchal
Type of Javascript

1) External Javascript
2) Internal Javascript
Like · Comment ·
Admin and 2 other like this
Download Android App