Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript PHP jQuery
i have two page on is test1.html and test2.html
 

 
on test1.html contain code >>
Quote:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#test").click(function(){
$("p:last").removeClass("intro").addClass("main");
});
});
</script>
<style type="text/css">
.intro
{
color:red;
}
.main
{
background-color:yellow;
}
</style>
</head>
<body>
 
<a href="test2.html" id="test">go to next</a>
 
</body>
</html

 

 
and on test2.html >>
Quote:
Quote:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("#test").click(function(){
$("p:last").removeClass("intro").addClass("main");
});
});
</script>
<style type="text/css">
.intro
{
color:red;
}
.main
{
background-color:yellow;
}
</style>
</head>
<body>

This is a paragraph.

 

</body>
</html

 

 
now when i click on go to next then page will be redirected to test2.html
 
then on test2.html page intro class rename with main class (
Posted 1-Apr-13 20:11pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1. $("#test").click event on the second page will not be fired as it the element is not in the test2.html
2. $("#test").click event on the first page will have no effect as the element p is not in the first page.
 
3. So the javascript or jquery works only for the page it belongs to not for other pages.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 BillWoodruff 85
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 2 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100