What so special in Windows 8

We all know Microsoft  Windows OS is most popular in Computer world. And Microsoft is releasing every new version of Win OS with much more options/features. Currently they’re planning to release new Version (Win 8) in upcoming year (2012 – first half).

Windows 8 Logo

This version of windows coming with more features, those are:-

1) Tablet version

2) Metro UI with HTML, JavaScript and CSS

3) Tiles with up to date

4) Push notification

5) 3D fully glassy aero interface

6) Windows explorer with ribbon

7) New windows calender (and Taskbar design)

8) New start menu

9)  Windows media player with high definition and 3D blu ray support

10) Lock screen feature with widgets like time and push notifications

11) Apps feature

12) ISO and VHD support

13) Auto windows up date

14)  Better security

15) Faster bootup

16) Microsoft Lync

17) Windows 8 will have USB 3 0

18) Much better File Management

19) IE 10Internet Explorer (ie) 10

and more worth is waiting….

Jquery Contains with case-(in)sensitive

In this post I am going to explain about jQuery Contains method with case insensitive.

First small talk about jQuery, It one of the popular java script  library which is ready to use. The jQuery’s tag line is “WRITE LESS, DO MORE.” I feel  it is true, because we can get more functionality with less code lines.

JQuery logo

Just few days before, I worked with jQuery Selector using Contains. Contains is returns the elements which are the elements have that part of text. But, I faced a problem. For example I am search for “ABC” $(‘#ShowItems li:contains(“ABC”)’). It is not showing “abc” contains elements. Because, Contains method is case sensitive.

So, I found a way to make jQuery selector contains extender. This we can do in jQuery easily.

we need to add this script

//Extend selector
$.extend($.expr[':'], {
‘containsi’: function (elem, i, match, array) {
/* For example $(‘#ShowItems li:containsi(“Share”)’), then match[3] will be Share*/
return (elem.textContent || elem.innerText || ”).toLowerCase().indexOf((match[3] || “”).toLowerCase()) >= 0;
}
});
Full HTML Code :-

<html>
<head>
<title>Jquery Contains with case-[in]sensitive</title>
</head>
<body> 

<ul id=”ShowItems”>
<li>Share Our Ideas</li>
<li>More you share, More you gain</li>
<li>Enjoy while coding..!</li>
</ul>
<script src=”http://code.jquery.com/jquery-1.5.1.min.js” type=”text/javascript”></script>
<script type=”text/javascript”>
//Extend selector
$.extend($.expr[':'], {
‘containsi’: function (elem, i, match, array) {
/* For example $(‘#ShowItems li:containsi(“Share”)’), then match[3] will be Share*/
return (elem.textContent || elem.innerText || ”).toLowerCase().indexOf((match[3] || “”).toLowerCase()) >= 0;
}
});

//This is contains will look with case sensitive
$(‘#ShowItems li:contains(“Share”)’).css(‘color’, ‘red’);
//This is for case-insensitive
$(‘#ShowItems li:containsi(“Share”)’).css(‘text-decoration’, ‘underline’);
</script>
</body>
</html>

The out put will come like this

  • Share Our Ideas
  • More you share, More you gain
  • Enjoy while coding..!

First when I try with Contains like this

//This is contains will look with case sensitive
$(‘#ShowItems li:contains(“Share“)’).css(‘color’, ‘red’);

it only returning first one which contains Share, case sensitive.

When I try to call containsi selector

$(‘#ShowItems li:containsi(“Share“)’).css(‘text-decoration’, ‘underline’);

it is returns 2 elements, which having “Share” and “share“. Here it is case insensitive.

Jquery makes my work easy! I love it!

Enjoy while coding..!

Thanks,

Naga harish.

Break and continue in jQuery each function(loop)

This is post I am going to explain about break and continue in jQuery each function(loop).

jQuery’s functions like $.each( Object obj, Function fn ) or $().each() are not loops.These are iterative functions. $().each() is used to iterate jQuery object and you can use $.each( Object obj, Function fn ) to iterate over anything (for example, an array).

jQuery loops are not like javascript (for and while loop) loops. We can use ‘break;’ and ‘continue;’ inside a loop in javascript. But it will not work in jQuery loop ($().each()). :(

But there is way for it, if you need the same functionality for a jQuery loop.

We can use ‘return false;’ inside a jQuery loop to break it.

jQuery loops are functions. So when we use ‘return false;’ from a function, it will immediately stop execution of function. So, it will work llike ‘break;’.

Similarly if we use ‘return;’ (without passing true or false) it will work as ‘continue’;

Check with this below example

First normal javascript

function Demo()
{
for(var i=0;i<=10;i++)
{
if(i==2)

continue;

if(i==4)

break;

document.write(i+’<br/>’);

}
}

Output:

0

1

3

Now jQuery

 

function Demo()

{

$.each([0,1,2,3,4,5], function()

{

if(this == 2)

continue;

if(this == 4)

break;

document.write(this+’<br/>’);

});

}

 

Output:

0

1

3

It work same like below each function also

 

function Demo()

{

$(‘div’).each(function(index) {

if(index == 2)

continue;

if(index == 4)

break;

$(this).css(‘color’,'red’);

});

}

Hope this post helpful for you. if is there any better way then this please let me know.

Enjoy while coding..!

Thanks,

Naga Harish.

Follow

Get every new post delivered to your Inbox.

Join 109 other followers