Home
 

Assign query result to variable

Download jquery-1.3.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        var input = $("form input:text");
        $("div").text("For this type jQuery found " + input.length + ".");
    });
</script>

     <form>
      <input type="text" />
     </form>
     <div></div>

Form input

Download jquery-1.3.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("form input").css("border", "2px solid red");
  });
</script>

  <form>
	<label>First Name:</label>
	<input name="name" />
	<fieldset>
	  <label>Last Name:</label>
	  <input name="newsletter" />
	</fieldset>
  </form>

Matches all input elements of type text.htm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("form input:text").css({background:"yellow"});
});
</script>

<form>
  <input type="text" />
</form>

Add class in jquery

Adds class to all divs that have a paragraph inside of them.
Download jquery-1.3.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("div:has(p)").css("color","red");
            //  $("div > p").css("border", "1px solid gray");
	});
</script>

<div><p>Hello in a paragraph</p></div>

Output :
Hello in a paragraph

jQuery loaded a class and running

Download jquery-1.3.2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script type='text/javascript' src='js/jquery-1.3.2.js'></script>
<script type='text/javascript'>
if ($) {
  $(document).ready(
    function() {
      $('p').addClass('Loaded');
      $('p').text('jQuery loaded and running!');
    }
  );
}
</script>
<style type='text/css'>
p.Loaded {
    color: green;
    border: 1px solid green;
}
</style>

<p>
	jQuery is not loaded.
</p>

Output :
jQuery loaded and running!

Redirection of files or folders using htaccess

Some times we require temporary or permanent redirection of files or folders to some other files or folders. There could be any reason, it may be outdated, may be temporary unavailable or any thing. You can use htaccess file to redirect to new destination.

1
Redirect /olddirectory/oldfile.html http://www.domainname.com/newdirectory/newfile.html

Disable directory listing or browsing using htaccess

This simple code will disable all directory listing for any directory. This typically required in apache, cpanel based hosting accounts. By default directory listings are enabled. By using below code you can disable listing of any folder.

1
IndexIgnore *

 
 
 

Categories

Tag