Skip to content

tito433/Bootstrap-device-detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

#Bootstrap device detector


In some cases we need to know currect device to perform some task. Say load 100 items on large device(lg) or load 20 items on mobile device(xs). This plugin will tell you what device currently it is. It also detect browser resize event to trigger device change event only if you provide a call back function!

Installation

HTML HEAD:

<script src="js/deviceNow.min.js"></script>

JavaScript: (instant detection)

<script type="text/javascript">
        $(function () {
        	//returns "xs", "sm", "md" or "lg"
           var currentDevice=jQuery().deviceNow();

           if("lg"==currentDevice){
           		//do something for large device
           }else if("xs"==currentDevice){
           		//do something for mobile device
           }
        });
</script>

JavaScript: (with callback when device changes)

<script type="text/javascript">
        $(function () {
        	
        	jQuery().deviceNow(function(device){

	              alert("Current device changed to:"+device);

	              if("lg"==device){
		           		//do something for large device
		          }else if("xs"==device){
		           		//do something for mobile device
		          }
	        });

        });
</script>

As simple as it is!

About

Detect bootstrap device

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published