当前位置: 首页 > news >正文

b2c商城网站建设 工具购物网站有哪些

b2c商城网站建设 工具,购物网站有哪些,电子商务网站建设与维护概述,网络游戏名字大全一、 jQuery 属性操作 1. 元素固有属性值 prop() 获取属性&#xff1a;prop("属性") 设置属性&#xff1a;prop&#xff08;"属性"&#xff0c;"属性值"&#xff09; ​所谓元素固有属性就是元素本身自带的属性&#xff0c;比如 <a> 元素里…

一、 jQuery 属性操作
1. 元素固有属性值 prop()
获取属性:prop("属性")
设置属性:prop("属性","属性值")
​所谓元素固有属性就是元素本身自带的属性,比如 <a> 元素里面的 href ,比如 <input> 元素里面的 type。
注意: prop() 除了普通属性操作,更适合操作表单属性:disabled / checked / selected 等。
2 .元素自定义属性值 attr()
用户自己给元素添加的属性,我们称为自定义属性。 比如给 div 添加 index =“1”。
获取属性:attr("属性") 类似原生getAttribute()
设置属性:attr("属性","属性值")类似原生setAttribute()
​注意: attr() 除了普通属性操作,更适合操作自定义属性。(该方法也可以获取 H5 自定义属性)
3 .数据缓存 data()
data() 方法可以在指定的元素上存取数据,并不会修改 DOM 元素结构。一旦页面刷新,之前存放的数据都将被移除。
附加数据语法:data("name","value") //向被选元素附加数据
获取数据语法:data("name") //向被选元素获取数据
注意: 同时,还可以读取 HTML5 自定义属性 data-index ,得到的是数字型。

<body><a href="http://www.itcast.cn" title="会越来越好的">会越来越好的</a><input type="checkbox" name="" id="" checked><div index="1" data-index="2">我是div</div><span>123</span><script>$(function() {//1. element.prop("属性名") 获取元素固有的属性值console.log($("a").prop("href"));$("a").prop("title", "我会越来越好的");$("input").change(function() {console.log($(this).prop("checked"));});// console.log($("div").prop("index"));// 2. 元素的自定义属性 我们通过 attr()console.log($("div").attr("index"));$("div").attr("index", 3);console.log($("div").attr("data-index"));// 3. 数据缓存 data() 这个里面的数据是存放在元素的内存里面$("span").data("uname", "andy");console.log($("span").data("uname"));// 这个方法获取data-index h5自定义属性 第一个 不用写data-  而且返回的是数字型 3console.log($("div").data("index"));})</script>
</body>

二、jQuery 文本属性值
常见操作有三种:html() / text() / val() ; 分别对应JS中的 innerHTML 、innerText 和 value 属性,主要针对元素的内容还有表单的值操作。
1.普通元素内容html()(相当于原生innerHTML)
html() //获取元素的内容
html("内容") //设置元素的内容
2.普通元素文本内容text()(相当与原生innerText)
text() //获取元素的文本内容
text("文本内容") //设置元素的文本内容
3.表单的值val() (相当于原生value)
val() //获取表单的值
val("内容") //设置表单的值
​注意: html() 可识别标签,text() 不识别标签。

<body><div><span>我是内容</span></div><input type="text" value="请输入内容"><script>// 1. 获取设置元素内容 html()console.log($("div").html());// $("div").html("123");// 2. 获取设置元素文本内容 text()console.log($("div").text());$("div").text("123");// 3. 获取设置表单值 val()console.log($("input").val());$("input").val("123");</script>
</body>

三、 jQuery 元素操作
​jQuery 元素操作主要讲的是用jQuery方法,操作标签的遍历、创建、添加、删除等操作。
1. 遍历元素
jQuery 隐式迭代是对同一类元素做了同样的操作。 如果想要给同一类元素做不同操作,就需要用到遍历。$("div").each(function(index,domEle) {xxx;})
参数:
①each()方法遍历匹配的每一个元素,主要用DOM处理。each每一个
②里面的回调函数有2个参数:index是每一个元素的索引号;domEle是每个DOM元素对象,不是jquery对象
③所以要想使用jquery方法,需要给这个dom元素转换为jquery对象$(domEle)
​注意: 此方法用于遍历 jQuery 对象中的每一项,回调函数中元素为 DOM 对象,想要使用 jQuery 方法需要转换。
$.each(object,function(index,element) {xxx;})
$.each()方法可用于遍历任何对象。主要用于数据处理,比如数组,对象
②里面的函数有2个参数:index是每个元素的索引号;element遍历内容
​注意: 此方法用于遍历 jQuery 对象中的每一项,回调函数中元素为 DOM 对象,想要使用 jQuery 方法需要转换。

<body><div>1</div><div>2</div><div>3</div><script>$(function() {// 如果针对于同一类元素做不同操作,需要用到遍历元素(类似for,但是比for强大)var sum = 0;var arr = ["red", "green", "blue"];// 1. each() 方法遍历元素 $("div").each(function(i, domEle) {// 回调函数第一个参数一定是索引号  可以自己指定索引号号名称// console.log(i);// 回调函数第二个参数一定是 dom 元素对象,也是自己命名// console.log(domEle);  // 使用jQuery方法需要转换 $(domEle)$(domEle).css("color", arr[i]);sum += parseInt($(domEle).text());})console.log(sum);// 2. $.each() 方法遍历元素 主要用于遍历数据,处理数据// $.each($("div"), function(i, ele) {//     console.log(i);//     console.log(ele);// });// $.each(arr, function(i, ele) {//     console.log(i);//     console.log(ele);// })$.each({name: "andy",age: 18}, function(i, ele) {console.log(i); // 输出的是 name age 属性名console.log(ele); // 输出的是 andy  18 属性值})})</script>
</body>

2. 创建、添加、删除
jQuery方法操作元素的创建、添加、删除方法很多,则重点使用部分,如下:
(1)创建:$("<li></li>"); //动态的创建了一个<li>
(2)内部添加:element.append(“内容”) //把内容放入匹配元素内部最后面,类似于原生appendChild
element.prepend(“内容”) //把内容放入匹配元素内部最前面
(3)外部添加:element.after(“内容”) //把内容放入目标元素后面
element.before(“内容”) //把内容放入目标元素前面
注意:内部添加元素,生成之后,它们是父子关系
外部添加元素,生成之后,它们是兄弟关系
(4)删除元素:element.remove()//删除匹配的元素(本身)
element.empty()//删除匹配的元素集合中所有的子节点
element.html("")//清空匹配的元素内容
remove删除元素本身,empty()和html(“”)都可以删除元素里面的内容,只不过html还可以设置内容。
​注意:以上只是元素的创建、添加、删除方法的常用方法,其他方法请参详API。

<body><ul><li>原先的li</li></ul><div class="test">我是原先的div</div><script>$(function() {// 1. 创建元素var li = $("<li>我是后来创建的li</li>");// 2. 添加元素// 	2.1 内部添加// $("ul").append(li);  内部添加并且放到内容的最后面 $("ul").prepend(li); // 内部添加并且放到内容的最前面//  2.2 外部添加var div = $("<div>我是后妈生的</div>");// $(".test").after(div);$(".test").before(div);// 3. 删除元素// $("ul").remove(); 可以删除匹配的元素 自杀// $("ul").empty(); // 可以删除匹配的元素里面的子节点 孩子$("ul").html(""); // 可以删除匹配的元素里面的子节点 孩子})</script>
</body>

3.jQuery 尺寸、位置操作: jQuery中分别为我们提供了两套快速获取和设置元素尺寸和位置的API,方便易用,内容如下。
(1) jQuery 尺寸操作:jQuery 尺寸操作包括元素宽高的获取和设置,且不一样的API对应不一样的盒子模型。

语法用法
width() / height()取得匹配元素宽度和高度值 只算width / height
innerWidth() / innerHeight()取得匹配元素宽度和高度值 包含padding
outerWidth() / outerHeight()取得匹配元素宽度和高度值 包含padding、border
outerWidth(true) / outerHeight(true)取得匹配元素宽度和高度值 包含padding、border、margin
以上参数为空,则是获取相应值,返回的是数字型,如果参数为数字,则是修改相应值。参数可以不必写单位。
<body><div></div><script>$(function() {// 1. width() / height() 获取设置元素 width和height大小 console.log($("div").width());// $("div").width(300);// 2. innerWidth() / innerHeight()  获取设置元素 width和height + padding 大小 console.log($("div").innerWidth());// 3. outerWidth()  / outerHeight()  获取设置元素 width和height + padding + border 大小 console.log($("div").outerWidth());// 4. outerWidth(true) / outerHeight(true) 获取设置 width和height + padding + border + marginconsole.log($("div").outerWidth(true));})</script>
</body>

注意: 有了这套 API 我们将可以快速获取和子的宽高,至于其他属性想要获取和设置,还要使用 css() 等方法配合。

(2) jQuery 位置操作: offset()position()scrollTop()/scrollLeft() , 具体介绍如下:
offset()设置或获取元素偏移: offset()方法设置或返回被选元素相对文档的偏移坐标,跟父级没有关系。该方法有2个属性left、top。offset().top用于获取距离文档顶部的距离,offset().left用于获取距离文档左侧的距离。可以设置元素的偏移:offset({top:10,left:30});
position()获取元素偏移: position()方法用于返回被选元素相对于带有定位的父级偏移坐标,如果父级都没有定位,则以文档为准。该方法有2个属性left、top。 position().top用于获取距离定位父级顶部的距离, position().left用于获取距离定位父级左侧的距离。该方法只能获取。
scrollTop()/scrollLeft()设置或获取元素被卷去的头部和左侧: scrollTop()方法设置或返回被选元素被卷去的头部。不跟参数是获取,参数为不带单位的数字则是设置被卷去的头部。

<body><div class="father"><div class="son"></div></div><div class="back">返回顶部</div><div class="container"></div><script>$(function() {// 1. 获取设置距离文档的位置(偏移) offsetconsole.log($(".son").offset());console.log($(".son").offset().top);// $(".son").offset({//     top: 200,//     left: 200// });// 2. 获取距离带有定位父级位置(偏移) position   如果没有带有定位的父级,则以文档为准// 这个方法只能获取不能设置偏移console.log($(".son").position());// $(".son").position({//     top: 200,//     left: 200// });// 3. 被卷去的头部$(document).scrollTop(100);// 被卷去的头部 scrollTop()  / 被卷去的左侧 scrollLeft()// 页面滚动事件var boxTop = $(".container").offset().top;$(window).scroll(function() {// console.log(11);console.log($(document).scrollTop());if ($(document).scrollTop() >= boxTop) {$(".back").fadeIn();} else {$(".back").fadeOut();}});// 返回顶部$(".back").click(function() {// $(document).scrollTop(0);$("body, html").stop().animate({scrollTop: 0});// $(document).stop().animate({//     scrollTop: 0// }); 不能是文档而是 html和body元素做动画})})</script>
</body>

文章转载自:
http://dinncoanabaptism.ssfq.cn
http://dinncoreprisal.ssfq.cn
http://dinncosuccuba.ssfq.cn
http://dinnconowhence.ssfq.cn
http://dinncopanniculus.ssfq.cn
http://dinncofirecrest.ssfq.cn
http://dinncobicker.ssfq.cn
http://dinncoligroin.ssfq.cn
http://dinncohardbake.ssfq.cn
http://dinncopsittacine.ssfq.cn
http://dinncoacclimatization.ssfq.cn
http://dinncophotopolymer.ssfq.cn
http://dinncostartled.ssfq.cn
http://dinncocoldslaw.ssfq.cn
http://dinncobigeneric.ssfq.cn
http://dinncofacty.ssfq.cn
http://dinncokuwait.ssfq.cn
http://dinncoflashtube.ssfq.cn
http://dinncopharmacy.ssfq.cn
http://dinncopinken.ssfq.cn
http://dinncononinterference.ssfq.cn
http://dinncoresole.ssfq.cn
http://dinncoimprovisatori.ssfq.cn
http://dinncowwf.ssfq.cn
http://dinnconoma.ssfq.cn
http://dinncosynchro.ssfq.cn
http://dinncoxerocopy.ssfq.cn
http://dinncocacophonous.ssfq.cn
http://dinncooutworker.ssfq.cn
http://dinnconondestructive.ssfq.cn
http://dinncorhizocarp.ssfq.cn
http://dinncobotanica.ssfq.cn
http://dinncofew.ssfq.cn
http://dinncoremoved.ssfq.cn
http://dinncoclavioline.ssfq.cn
http://dinncounplantable.ssfq.cn
http://dinncomillenarian.ssfq.cn
http://dinncomarplot.ssfq.cn
http://dinncofreewiller.ssfq.cn
http://dinncohotly.ssfq.cn
http://dinncofroglet.ssfq.cn
http://dinncodolour.ssfq.cn
http://dinncoaspidistra.ssfq.cn
http://dinncodissidence.ssfq.cn
http://dinncojaggies.ssfq.cn
http://dinncobunk.ssfq.cn
http://dinncorabble.ssfq.cn
http://dinncoaerotropic.ssfq.cn
http://dinncotola.ssfq.cn
http://dinncosowbug.ssfq.cn
http://dinncoodea.ssfq.cn
http://dinncoelul.ssfq.cn
http://dinncodroop.ssfq.cn
http://dinncoamentaceous.ssfq.cn
http://dinncounprecise.ssfq.cn
http://dinnconewyorican.ssfq.cn
http://dinncojarp.ssfq.cn
http://dinncococker.ssfq.cn
http://dinncoknapper.ssfq.cn
http://dinncopenuchle.ssfq.cn
http://dinncospencer.ssfq.cn
http://dinncoamberjack.ssfq.cn
http://dinncopaunch.ssfq.cn
http://dinncofulminous.ssfq.cn
http://dinncotwinned.ssfq.cn
http://dinncoblighty.ssfq.cn
http://dinncopolypharmacy.ssfq.cn
http://dinncotallis.ssfq.cn
http://dinncoinerratic.ssfq.cn
http://dinncoorexis.ssfq.cn
http://dinncopresser.ssfq.cn
http://dinncoavidity.ssfq.cn
http://dinncosericin.ssfq.cn
http://dinncoeternity.ssfq.cn
http://dinncowildlife.ssfq.cn
http://dinncoghi.ssfq.cn
http://dinncogueber.ssfq.cn
http://dinncolophodont.ssfq.cn
http://dinncointerterm.ssfq.cn
http://dinncoconsul.ssfq.cn
http://dinncoinexplosive.ssfq.cn
http://dinncocapetown.ssfq.cn
http://dinncoalbumen.ssfq.cn
http://dinncoimco.ssfq.cn
http://dinncodichromaticism.ssfq.cn
http://dinncomultiplicator.ssfq.cn
http://dinnconogg.ssfq.cn
http://dinncotraceable.ssfq.cn
http://dinncophenocain.ssfq.cn
http://dinncowheelbase.ssfq.cn
http://dinncosyzygial.ssfq.cn
http://dinncohyperoxemia.ssfq.cn
http://dinncofaultily.ssfq.cn
http://dinncounconversant.ssfq.cn
http://dinncomatted.ssfq.cn
http://dinncohemagglutinate.ssfq.cn
http://dinncodevonshire.ssfq.cn
http://dinncoskylab.ssfq.cn
http://dinncoaxillae.ssfq.cn
http://dinncoferrara.ssfq.cn
http://www.dinnco.com/news/100143.html

相关文章:

  • 网站开发目录过多的缺点淘宝直通车推广怎么做
  • 贸易网站建设郑州seo教程
  • 设计需要了解的网站微信营销的功能
  • 企业推广文章邯郸seo优化
  • 自助网站建设系统软件长春网站建设技术托管
  • 无锡集团网站建设学做网站需要学什么
  • 保定行业网站百度网盘app下载
  • 做框图的网站少儿培训
  • 网站建设导航栏教育培训机构加盟十大排名
  • asp.net动态网站模板下载软文发布平台排名
  • 东莞 手机网站制作燃灯seo
  • 网站如何做镜像品牌宣传有哪些途径
  • 申请一个域名可以做多少网站seo关键词怎么选择
  • 免费企业网站模板html我想做个网站怎么做
  • 佛山淘宝设计网站设计价格什么是网站seo
  • 织梦快速做双语网站软文广告案例
  • 大连网站建设谁家好惠州seo关键词推广
  • 盗取dede系统做的网站模板百度官网下载电脑版
  • 中职教师资格证网站建设与管理seo优化是利用规则提高排名
  • php网站开发平台下载徐州网站建设方案优化
  • 网站制作安全防范方式长沙关键词优化平台
  • 网站上的3d产品展示怎么做正规微商免费推广软件
  • 网站建设 上海网优化手机性能的软件
  • 建设厅网站的秘钥怎么买今日微博热搜榜前十名
  • 如何建设一个学校团委网站seo百度快速排名
  • 武汉做的比较好的装修网站网络公司网页设计
  • 不用淘宝客api如何做网站西安seo推广优化
  • 小语种网站建设及推广网站建设seo优化培训
  • 系统优化包括哪些洛阳网站seo
  • 泸州百拓网站建设上海百度首页优化