jQuery: JS Alternativen

$.each() // replace myData with array for(var input = myData, key = 0, val = input[key]; key < input.length; key++, val = input[key]) { console.log(key,val) } DOM Selector document.querySelectorAll(%strSelectors%);  

Read More

Vertikaler snap scroll

Mit einer Kombination der mousewheel1 und touchSwipe-Plugins für jQuery lässt sich ein vertikaler Scroll realisieren, der jeweils auf das nächste Element einschnappt. <script type=”text/javascript” src=”js/jquery.min.js”></script> <script type=”text/javascript” src=”js/jquery.mousewheel.js”></script> <script type=”text/javascript” src=”js/jquery.touchSwipe.min.js”></script>   <div id=”wrap”> <div class=”section”>Section 1</div> <div class=”section”>Section 2</div> <div class=”section”>Section 3</div> <div class=”section”>Section 4</div> </div>   $(document).ready(function() { // visible element if(location.hash == […]

Read More

Plugins

Position Arbeiten mit der using-Option1. element.position({ using: function( position, data ) { // Information about the element being positioned data.element // jQuery object containing the element data.element.element // Left offset of the element data.element.left // Top offset of the element data.element.top // Width of the element (including padding and border) data.element.width // Height of the […]

Read More

jQuery: Basics

CND Einbindung mit lokalem Fallback <script src=”//code.jquery.com/jquery-1.11.0.min.js”></script> <script> if (!window.jQuery) { document.write(‘<script src=”/path/to/your/jquery”><\/script>’); } </script>   Bubbling stoppen $(‘#element’).on(‘click’, function(event) { event.stopPropagation(); console.log(‘bubbling stopped’); });  

Read More