吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 383|回复: 11
收起左侧

[资源求助] html源码修改

[复制链接]
钱途迷茫 发表于 2024-3-22 23:18
40吾爱币
从别人的网页扒了个轮播图模块下来,想在一个页面里多复制几个模块出来,结果搞不定,JS那块学才开始学,应该是变量之类的重名了导致的,请大佬帮忙另外复制5个轮播模块下来,并告知一下复制后需要修改哪些地方

https://wwp.lanzout.com/i4r651s9s18b

最佳答案

查看完整内容

[mw_shl_code=html,true] $(document).ready(function(){ $(".moban_sc a").each(function(){ if($(this).attr("href")==""){ $(this).css("display","none"); } }); }); body{ background:#f5ece3 } ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"] ["3/1.jpg","3 ...

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

gllsqgg 发表于 2024-3-22 23:18
[HTML] 纯文本查看 复制代码
<!DOCTYPE HTML Powered By "EMewCMS By [email]287064290@qq.com[/email]">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">

<meta name="keywords" content=""/>
<!-- Mobile Devices Support @begin -->
<meta content="telephone=no, address=no" name="format-detection">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- Mobile Devices Support @end -->
<link rel="stylesheet" type="text/css" href="static/css/moban.css">
<link rel="stylesheet" href="static/css/swiper.min.css">
<script type="text/javascript" src="static/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="static/js/swiper.min2.js"></script>
<script>
$(document).ready(function(){
$(".moban_sc a").each(function(){ 
	if($(this).attr("href")==""){ 
		$(this).css("display","none");
	}
});
});
</script>

<style>
body{
background:#f5ece3
}
</style>
</head>

<body>
<div id="moban">
<img src="2/1.jpg" width="100%">
	
	<!-- Swiper -->
    <div class="swiper-container">
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>
    </div>

    <div class="swiper-container">

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg"]
		</div>
    </div>
    <div class="swiper-container">
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>
    </div>

    <div class="swiper-container">

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg"]
		</div>
    </div>
    <div class="swiper-container">
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>
    </div>

		
<script type="text/javascript">
$.each($(".swiper-wrapper"), function(i, item) {
		var jq_item = $(item);
		var str_json = jq_item.html();
		var html_temp = "";
		if (str_json.length > 0) {
			var arr = JSON.parse(str_json);
			$.each(arr, function(i_s, item_s) {
				html_temp += '<div class="swiper-slide"><img src="' + item_s + '" /></div>';
			});
		}
		jq_item.html(html_temp);
	});
</script>
	


</div>

<script type="text/javascript">
	var swiper = new Swiper('.swiper-container', {
			loop: true,
		  spaceBetween: 30,
		  centeredSlides: true,
		  autoplay: {
			delay: 3500,
			disableOnInteraction: false,
		  },
    });
</script>


</body>
</html>
gllsqgg 发表于 2024-3-22 23:37
...这,估计就是js的选择器用的是id,然后你复制的话id也就重复了,但是网页里不能存在同名id,name
gllsqgg 发表于 2024-3-22 23:59
好吧,也不是id的问题,
一个是,<img src="2/1.png" width="100%">  #这里的png应该是jpg,因为不存在这个文件。
然后是:
<script type="text/javascript">
$.each($(".swiper-wrapper"), function(i, item) {
...
</script>
</div> #这里的div放<script type="text/javascript">前面,div一般情况不要包着script
然后
    <div class="swiper-container">
                <div class="swiper-wrapper">
               
                        ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
               
                </div>
    </div>
这部分复制就行了,还有改名2/1.jpg,3/1.jpg  就可以轮播不同文件夹里面的图片了。
当然这部分可以用js写for 和 innerhtml去修改,
 楼主| 钱途迷茫 发表于 2024-3-23 00:04
gllsqgg 发表于 2024-3-22 23:59
好吧,也不是id的问题,
一个是,  #这里的png应该是jpg,因为不存在这个文件。
然后是:

麻烦发一下完整的html代码吧,复制5个模块出来,都调用2文件夹里的图片就行了
gllsqgg 发表于 2024-3-23 00:05
本帖最后由 gllsqgg 于 2024-3-23 00:07 编辑

[HTML] 纯文本查看 复制代码
<!DOCTYPE HTML Powered By "EMewCMS By 287064290@qq.com">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">

<meta name="keywords" content=""/>
<!-- Mobile Devices Support @begin -->
<meta content="telephone=no, address=no" name="format-detection">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<!-- Mobile Devices Support @End -->
<link rel="stylesheet" type="text/css" href="static/css/moban.css">
<link rel="stylesheet" href="static/css/swiper.min.css">
<script type="text/javascript" src="static/js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="static/js/swiper.min2.js"></script>
<script>
$(document).ready(function(){
$(".moban_sc a").each(function(){ 
        if($(this).attr("href")==""){ 
                $(this).css("display","none");
        }
});
});
</script>

<style>
body{
background:#f5ece3
}
</style>
</head>

<body>
<div id="moban">
<img src="2/1.jpg" width="100%">
        
        <!-- Swiper -->
    <div class="swiper-container">
                <div class="swiper-wrapper">
                        ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
                </div>

                <div class="swiper-wrapper">
                        ["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
                </div>
                
                <div class="swiper-wrapper">
                        ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
                </div>

                <div class="swiper-wrapper">
                        ["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
                </div>
                
                <div class="swiper-wrapper">
                        ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
                </div>

                <div class="swiper-wrapper">
                        ["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
                </div>
                
                <div class="swiper-wrapper">
                        ["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
                </div>

                <div class="swiper-wrapper">
                        ["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
                </div>
                
    </div>
<script type="text/javascript">
$.each($(".swiper-wrapper"), function(i, item) {
                var jq_item = $(item);
                var str_json = jq_item.html();
                var html_temp = "";
                if (str_json.length > 0) {
                        var arr = JSON.parse(str_json);
                        $.each(arr, function(i_s, item_s) {
                                html_temp += '<div class="swiper-slide"><img src="' + item_s + '" /></div>';
                        });
                }
                jq_item.html(html_temp);
        });
</script>
        


</div>

<script type="text/javascript">
        var swiper = new Swiper('.swiper-container', {
                  spaceBetween: 30,
                  centeredSlides: true,
                  autoplay: {
                        delay: 3500,
                        disableOnInteraction: false,
                  },
    });
</script>


</body>
</html>
 楼主| 钱途迷茫 发表于 2024-3-23 00:10
本帖最后由 钱途迷茫 于 2024-3-23 00:12 编辑
gllsqgg 发表于 2024-3-23 00:05
[mw_shl_code=html,true]

有两个问题
1、滑动任意模块,其他模块也会跟着滑动,需要完全独立控制
2、手动播放图片,最后一张再往后滑动就变空白了,不像之前一样可以循环播放
gllsqgg 发表于 2024-3-23 00:13
[JavaScript] 纯文本查看 复制代码
<script type="text/javascript">
        var swiper = new Swiper('.swiper-container', {
                        loop: true,
                  spaceBetween: 30,
                  centeredSlides: true,
                  autoplay: {
                        delay: 3500,
                        disableOnInteraction: false,
                  },
    });
</script>

swiper   初始化的时候添加 loop: true, 就可以了
 楼主| 钱途迷茫 发表于 2024-3-23 00:15
gllsqgg 发表于 2024-3-23 00:13
[mw_shl_code=javascript,true]
        var swiper = new Swiper('.swiper-container', {
              ...

还是和之前一样的情况
gllsqgg 发表于 2024-3-23 00:17
[HTML] 纯文本查看 复制代码
    <div class="swiper-container">
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>
    </div>


	
    <div class="swiper-container">

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
		</div>
		
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
		</div>
		
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
		</div>
		
		<div class="swiper-wrapper">
			["2/1.jpg","2/2.jpg","2/3.jpg","2/4.jpg","2/5.jpg","2/6.jpg","2/7.jpg","2/8.jpg"]
		</div>

		<div class="swiper-wrapper">
			["3/1.jpg","3/2.jpg","3/3.jpg","3/4.jpg","3/5.jpg","3/6.jpg","3/7.jpg","3/8.jpg"]
		</div>
		
    </div>


滑动是swiper-wrapper控制的, 不包在一起就可以了
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-12-13 16:56

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表