markdowngistembed示例:jquery(代码片段)

author author     2022-12-15     675

关键词:

/* global twentyseventeenScreenReaderText */
/**
 * Theme functions file.
 *
 * Contains handlers for navigation and widget area.
 */

(function( $ ) 
	var masthead, menuToggle, siteNavContain, siteNavigation;

	function initMainNavigation( container ) 

		// Add dropdown toggle that displays child menu items.
		var dropdownToggle = $( '<button />',  'class': 'dropdown-toggle', 'aria-expanded': false )
			.append( twentyseventeenScreenReaderText.icon )
			.append( $( '<span />',  'class': 'screen-reader-text', text: twentyseventeenScreenReaderText.expand ) );

		container.find( '.menu-item-has-children > a, .page_item_has_children > a' ).after( dropdownToggle );

		// Set the active submenu dropdown toggle button initial state.
		container.find( '.current-menu-ancestor > button' )
			.addClass( 'toggled-on' )
			.attr( 'aria-expanded', 'true' )
			.find( '.screen-reader-text' )
			.text( twentyseventeenScreenReaderText.collapse );
		// Set the active submenu initial state.
		container.find( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' );

		container.find( '.dropdown-toggle' ).click( function( e ) 
			var _this = $( this ),
				screenReaderSpan = _this.find( '.screen-reader-text' );

			e.preventDefault();
			_this.toggleClass( 'toggled-on' );
			_this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' );

			_this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' );

			screenReaderSpan.text( screenReaderSpan.text() === twentyseventeenScreenReaderText.expand ? twentyseventeenScreenReaderText.collapse : twentyseventeenScreenReaderText.expand );
		);
	

	initMainNavigation( $( '.main-navigation' ) );

	masthead       = $( '#masthead' );
	menuToggle     = masthead.find( '.menu-toggle' );
	siteNavContain = masthead.find( '.main-navigation' );
	siteNavigation = masthead.find( '.main-navigation > div > ul' );

	// Enable menuToggle.
	(function() 

		// Return early if menuToggle is missing.
		if ( ! menuToggle.length ) 
			return;
		

		// Add an initial value for the attribute.
		menuToggle.attr( 'aria-expanded', 'false' );

		menuToggle.on( 'click.twentyseventeen', function() 
			siteNavContain.toggleClass( 'toggled-on' );

			$( this ).attr( 'aria-expanded', siteNavContain.hasClass( 'toggled-on' ) );
		);
	)();

	// Fix sub-menus for touch devices and better focus for hidden submenu items for accessibility.
	(function() 
		if ( ! siteNavigation.length || ! siteNavigation.children().length ) 
			return;
		

		// Toggle `focus` class to allow submenu access on tablets.
		function toggleFocusClassTouchScreen() 
			if ( 'none' === $( '.menu-toggle' ).css( 'display' ) ) 

				$( document.body ).on( 'touchstart.twentyseventeen', function( e ) 
					if ( ! $( e.target ).closest( '.main-navigation li' ).length ) 
						$( '.main-navigation li' ).removeClass( 'focus' );
					
				);

				siteNavigation.find( '.menu-item-has-children > a, .page_item_has_children > a' )
					.on( 'touchstart.twentyseventeen', function( e ) 
						var el = $( this ).parent( 'li' );

						if ( ! el.hasClass( 'focus' ) ) 
							e.preventDefault();
							el.toggleClass( 'focus' );
							el.siblings( '.focus' ).removeClass( 'focus' );
						
					);

			 else 
				siteNavigation.find( '.menu-item-has-children > a, .page_item_has_children > a' ).unbind( 'touchstart.twentyseventeen' );
			
		

		if ( 'ontouchstart' in window ) 
			$( window ).on( 'resize.twentyseventeen', toggleFocusClassTouchScreen );
			toggleFocusClassTouchScreen();
		

		siteNavigation.find( 'a' ).on( 'focus.twentyseventeen blur.twentyseventeen', function() 
			$( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' );
		);
	)();
)( jQuery );
## Gist Embed Sample: jQuery

Code is for display purposes only.

javascripttamañojavascriptstringdimensionesdinamicamenteanchotextonododomelementojquer(代码片段)

查看详情

jquer和封装的运动函数对比

<!doctypehtml><htmllang="en"><head> <metacharset="UTF-8"> <title>图片切换----->>jquer和封装的运动函数对比</title> <styletype="text/css"> #parent{ margin:500px500px 查看详情

jquer选择器

$(this) 选取当前HTML元素$("p.intro") 选取class为intro的<p>元素$("p:first") 选取第一个<p>元素$(‘p:first-child‘) 选取属于<p>的父元素中第一个为<p>的元素 查看详情

jquer的实用语法

jQuery选择器基本选择器全选      &("*")标签选择器   $("标签名")类选择器    $(".class")ID选择器    $("#id")选择器可以一次选择多个用,隔开  比如$("#id,.class") 层级选择器后代选择器      ... 查看详情

jquer.hoverdir的基本使用方法

首先引入JQ和HoverDir库,JQuer.HoverDir的下载地址: http://www.htmleaf.com/jQuery/Image-Effects/20141106396.html HTML部分: p.p1{margin:0.0px0.0px0.0px0.0px;font:20.0pxConsolas;color:#289c97}p.p2{margin 查看详情

自己动手做jquer插件

...n($){2$.extend({3sayHello:function(name){4alert(name+":hello");5}6});789})(jQuery);$.sayHello("meng");这种属于静态方法,直接调用即可。第二种方式:1(function($){23$.fn.redBg=f 查看详情

jquer属性offsetpositionscrolltop

尺寸操作1、获取宽高   a)jq对象.height/width():只有获取高度/宽度    尺寸,不包括padding和margin和border2、设置宽度  a)Jq对象.height/width("200px");  b)px可加可不加,不加不需要写双引号jQuery(funct 查看详情

jquer的简单应用

最后一篇了终于见到了成功的曙光在向我招手啊真是太兴奋啦!!!这次继续由我为大家带来JQuery的一些简单的应用吧 <!DOCTYPEhtml> <html> <headlang="en"> <metacharset="UTF-8"> <title></title> & 查看详情

jquer表单序列化加强版

相同name值会转化为一个数组$.fn.serializeObject=function(){varo={};vara=this.serializeArray();$.each(a,function(){if(o[this.name]!==undefined){if(!o[this.name].push){o[this.name]=[o[this.name]];}o[this.name].push 查看详情

angular4中使用jquer插件

有以下办法1在html文档头部引入jquery插件依赖,但是文档一旦变动就麻烦了2使用指令:http://www.cnblogs.com/liuyt/p/5810100.html指令是把利器,我感觉他在控件初始化过程中会被调用,所以就相当于控件初始化过程的拦截器一样,可以... 查看详情

jquer事件,选择器,dom操作

一、jQuery简介jQuery是一个 JavaScript库。(其实就是js,就是封装了,语法上有些不一样)jQuery极大地简化了JavaScript编程。jQuery库位于一个JavaScript文件中,其中包含了所有的jQuery函数。$:jQuery标识符二、jQuery选择器1.基本选择器... 查看详情

jquer.hoverdir的基本使用方法

HTML部分: <ul id="da-thumbs" class="da-thumbs"><li><ahref="#"><imgsrc="img/001.png"alt=""><divclass="hot-info"><h2>infenStudio</h2><em>< 查看详情

利用jquer+css简单实现购物网站的图片增大。

...上的时候,会让其变大,利于消费者观察,接下来我将用jQuery+css技术对其功能进行一简单实现。第一步:创建项目,并且在webapp下建立如下文件夹。第二步:代码编译:HTML+CSS:<!DOCTYPEhtml><html><head><metacharset="UTF-8"> 查看详情

jquer选项卡的制作

选项卡的制作思想是先制作选项卡的结构和样式,默认将某一个标题及与之相对应的内容设为选中状态,当鼠标放置在某标题上时,首先清除掉所有标题和内容的默认样式,将当前标题及与之相对应的内容设为选中样式状态。核... 查看详情

jquer和document加载失败--解决方案

今天在给select赋值的时候遇到了一个问题,jquery和dom加载不到对象 当执行$("#id").val()得到的值为null 执行document.getelementById("")的时候也是报错得到的值为undefined思来想去也不知道到底发生了什么问题,后来在网上发现了一... 查看详情

javascript【ver2】可视范囲に入ってたらfadein※要jquer(代码片段)

查看详情

jquer学习之jquery(function(){})与(function(){})(jquery)之间的区别

Jquery是优秀的Javascrīpt框架。我们现在来讨论下在Jquery中两个页面载入后执行的函数。$(document).ready(function(){ //在这里写你的代码...});在DOM加载完成时运行的代码可以简写成jQuery(function(){});(function($){})(jQuery)什么意思?(function(... 查看详情

在vue中如何引jquer

最近学习vue,习惯性的通过<script>标签引入jquery,写完后报错才想起来,这种方式在vue是不适用的。 1:因为已经安装了vue脚手架,所以需要在webpack中全局引入jquery   打开package.json文件,在里面加入这行代码... 查看详情