<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
<script src="jquery.js"></script>
<script>
// Your code goes here.
</script>
</body>
</html>
window.onload = function() {
alert( "welcome" );
}
$( document ).ready(function() {
// Your code here.
});
$( document ).ready(function() {
$( "a" ).click(function( event ) {
alert( "Thanks for visiting!" );
});
});
$( document ).ready(function() {
$( "a" ).click(function( event ) {
alert( "As you can see, the link no longer took you to jquery.com" );
event.preventDefault();
});
});
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Demo</title>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
<script src="jquery.js"></script>
<script>
$( document ).ready(function() {
$( "a" ).click(function( event ) {
alert( "The link will no longer take you to jquery.com" );
event.preventDefault();
});
});
</script>
</body>
</html>
Adding and Removing an HTML Class
Important: You must place the remaining jQuery examples inside the
ready
event so that your code executes when the document is ready to be worked on.
Another common task is adding or removing a class.
First, add some style information into the
<head>
of the document, like this:
1
2
3
4
5
|
|
Next, add the .addClass() call to the script:
1
|
|
All
<a>
elements are now bold.
To remove an existing class, use .removeClass():
1
|
|
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$( document ).ready(function() {
console.log( "document loaded" );
});
$( window ).load(function() {
console.log( "window loaded" );
});
</script>
</head>
<body>
<iframe src="http://manohargoud.in"></iframe>
</body>
</html>
No comments:
Post a Comment