【jquery获取当前页面的URL信息】教程文章相关的互联网学习教程文章

js,jQuery获取div高度

js方式:document.getElementById("cpmain").clientHeightjQuery方式:$(".cpmain").height()原文:http://www.cnblogs.com/zhushangwei/p/3599098.html

Jquery获取和修改img的src值的方法【代码】

转自:http://www.cnblogs.com/linhaixin/p/5581939.html获取(代码):$("#img")[0].src; 修改(代码): $("#img").attr(‘src‘,path); 原文:http://www.cnblogs.com/d8hao/p/7352446.html

jQuery08源码 (5140 , 6057) DOM操作 : 添加 删除 获取 包装 DOM筛选【代码】

jQuery.fn.extend({ //$(‘ul‘).find(‘li‘).css(‘background‘,‘red‘); //$(‘ul‘).find( $(‘li‘) ).css(‘background‘,‘red‘);find: function( selector ) {var i,ret = [],self = this,len = self.length;if ( typeof selector !== "string" ) {//$(‘li‘)//jQuery( selector )是li集合,filter调用者是li,filter返回的是满足function条件的li,li.prevObject=所有li,//外层 this.pushStack返回满足条件的li,li.p...

jquery 获取 元素.text( ) 里面的值 需要进行去空格去换行符操作

元素.val().replace(/\ +/g,"");//去掉空格.replace(/\ +/g,"") //去掉空格方法元素.text().replace(/[ ]/g,""); //去掉空格.replace(/[ ]/g,"")//去掉空格元素.val().replace(/[\r\n]/g,"");//去掉回车换行.replace(/[\r\n]/g,"")//去掉回车换行 .replace(/-/g, ‘‘) //去掉"-"号原文:https://www.cnblogs.com/sherryweb/p/13344075.html

jquery选择器 之 获取父级元素、同级元素、子元素【图】

一、获取父级元素1、 parent([expr]):获取指定元素的所有父级元素<div id="par_div"><a id="href_fir" href="#">href_fir</a><a id="href_sec" href="#">href_sec</a><a id="href_thr" href="#">href_thr</a></div><span id="par_span"><a id="href_fiv" href="#">href_fiv</a></span>$(document).ready(function(){$("a").parent().addClass(‘a_par‘);});二、获取同级元素:1、next([expr]):获取指定元素的下一个同级元素(注意...

jquery 通过attr获取属性只有一个值的解决【代码】

var a = [];$($(‘select.list[data-target="‘ + target + ‘"]‘).find("option:selected")).each(function(i, o){a[i] = $(o).attr(‘data-wkp‘);}); 原文:https://www.cnblogs.com/ghjbk/p/10011552.html

使用jquery获取url以及jquery获取url参数的方法(转)

使用jquery获取url以及使用jquery获取url参数是我们经常要用到的操作1、jquery获取url很简单,代码如下 <DIV style=‘border-width: 0px !important; margin: 1em 0px !important; padding: 1px !important; left: auto !important; top: auto !important; width: 740px; height: auto !important; text-align: left !important; right: auto !important; bottom: auto !important; line-height: 1.1em !important; font-family: ...

jquery 封装页面之间获取值【代码】

最近在项目中发页面传值比较繁琐。View → Control → View,或是Session、Cookie 的 感觉不是很好,于是封装了一个页面间的js方法,上码$.extend({request: function (name) {var search = decodeURI(location.search.slice(1)); //decodeURI 对中文进行转码,防止乱码出现var arr = search.split("&");for (var i = 0; i < arr.length; i++) {var ar = arr[i].split("=");if (ar[0] == name) {if (unescape(ar[1]) == ‘undefi...

jQuery中获取特定顺序子元素(子元素种类不定)的方法【代码】【图】

提出问题:只已知父元素和父元素中子元素的次序,怎么通过jQuery方法获得该元素? 1<p>第一部分:</p> 2<ul> 3<li>1</li> 4<li>2</li> // 选择这个子元素 5<li>3</li> 6</ul> 7<p>第二部分:</p> 8<ul> 9<li>4</li>10<li>5</li>11<li>6</li>12</ul>在不通过选择器的情况下(:first,:last,:nth-child()等),如何通过父元素来选择特定次序的子元素呢?方法一:eq(n)$("ul").children().eq(1).css("backgroundColor","blue");或者$("ul...

jquery实现JSON数据获取【代码】

html代码:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>获取JSON</title><script type="text/javascript" src="jquery-3.2.1.js"></script></head><body><div class="myDiv" style="color:aliceblue"></div><button class="btn">获取数据</button><script type="text/javascript">$(function(){$(".btn").click(function(){$(".myDiv").empty();//每次点击按钮清空原来数据,防止无限加载。$.ajax({url:"d...

jquery 获取背景图片的宽高

<script type="text/javascript">/* 拿到背景 */var url=$(‘.wrap‘).css(‘backgroundImage‘);/* 正则删掉不需要的信息,保留图片的链接 */var s = url.match(/url\((.*?)\)/);/* 返回一个数据,第一个是原图片链接,第二个才是删除不需要的东西的链接 */url =s[1];/* 删除头跟尾的引号 */if(url[0]=="\""){ url = url.slice(1,-1); console.log(url) }/* 把图片链接放到img的实例里面获取高宽 ,使用onload只能图片加载完之后才...

js和jquery获取父级元素、子级元素、兄弟元素的方法【代码】

先说一下js的获取方法,其要比JQUERY的方法麻烦很多,后面以JQUERY的方法作对比: <div id="dom"><div></div><div></div><div></div> </div> var a = docuemnt.getElementById("dom").getElementsByTagName_r("div"); 这是a的长度为3;必须处理一下才能用JS的那些属性。处理思想很简单就是遍历一下这些元素。把元素类型为空格而且是文本都删除。处理函数是这样的: function del_space(elem){var elem_child = elem.childNodes;//得...

js及jquery获取页面和元素的宽高

js:网页可见区域宽: document.body.clientWidth;(不含滚动条) 网页可见区域高: document.body.clientHeight;(不含滚动条) 网页可见区域宽: document.body.offsetWidth;(包括边线的宽); 网页可见区域高: document.body.offsetHeight;(包括边线的宽); 网页正文全文宽: document.body.scrollWidth; 网页正文全文高: document.body.scrollHeight; 网页被卷去的高(ff):document.body.scrollTop; 网页被卷去的高(ie): documen...

jquery cookie用法(获取cookie值,删除cookie)

cookie在jquery中有指定的cookie操作类,下面我先来介绍我们在使用cookie操作类时的一些问题,然后介绍正确的使用方法。使用JQuery操作cookie时 发生取的值不正确的问题:结果发现cookie有四个不同的属性: 名称,内容,域,路径 代码如下复制代码$.cookie(‘the_cookie‘); // 读取 cookie $.cookie(‘the_cookie‘, ‘the_value‘); // 存储 cookie $.cookie(‘the_cookie‘, ‘the_value‘, { expires: 7 }); // 存储一个带7天期...

jquery outerHeight方法 outerWidth方法 获取元素实际宽度高度

曾经写代码中,每当须要获取元素的实际“宽度”(这里的宽度是指元素宽度加上其边距)时,都须要用元素宽度加上margin值才行,今天发现一个叫outerWidth(options)的方法 ,非常好用。完毕了原来须要用一段来操作做的工作。这种方法不适用于window 和 document对象,能够使用.width()取代。以下是其简介outerWidth(options)获取第一个匹配元素外部宽度(默认包含补白和边框)。此方法对可见和隐藏元素均有效。返回值:Integer 一个整...