Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 位置swipejs的积分_Javascript_Jquery_Css_Jquery Mobile_Swipe - Fatal编程技术网

Javascript 位置swipejs的积分

Javascript 位置swipejs的积分,javascript,jquery,css,jquery-mobile,swipe,Javascript,Jquery,Css,Jquery Mobile,Swipe,我在jquery移动应用程序中添加了一个swipeJS照片幻灯片。我有一个问题。 我想要这样的点数来计算页面上的图片: 我在我的项目中添加了下面的html和css,但是它只显示垂直的点,没有任何格式,比如大/小 CSS: HTML: <div data-role="content" id="contentPics"> <div id='mySwipe' style='max-width:500px;margin:0 auto' class='swipe'>

我在jquery移动应用程序中添加了一个swipeJS照片幻灯片。我有一个问题。 我想要这样的点数来计算页面上的图片:

我在我的项目中添加了下面的html和css,但是它只显示垂直的点,没有任何格式,比如大/小

CSS:

HTML:

<div data-role="content" id="contentPics">
   <div id='mySwipe' style='max-width:500px;margin:0 auto' class='swipe'>
            <div class='swipe-wrap' id="picSwipe">
              <div><b>Pic</b></div>
              <div><b>Pic2</b></div>
            </div>
  </div>
    <nav>

    <ul id='position'>
      <li class='on'></li>
      <li></li>
      <li></li>
      <li></li>
    </ul>

  </nav>

照片
图2


不带点的小提琴示例:

请尝试以下代码

var bullets = document.getElementById('position').getElementsByTagName('li');
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
    callback: function (pos) {
        var i = bullets.length;
        while (i--) {
            bullets[i].className = ' ';
        }
        bullets[pos].className = 'on';
    }
});
这将根据幻灯片编号更改类上的


请在操作中查看它

尝试以下代码

var bullets = document.getElementById('position').getElementsByTagName('li');
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
    callback: function (pos) {
        var i = bullets.length;
        while (i--) {
            bullets[i].className = ' ';
        }
        bullets[pos].className = 'on';
    }
});
这将根据幻灯片编号更改类
上的

查看它的实际操作

工作示例:

Javascript:

var elem = document.getElementById('mySwipe');
var bullets = document.getElementById('position').getElementsByTagName('li');

window.mySwipe = Swipe(elem, {
    continuous: true,
    callback: function(pos) {      
      var i = bullets.length;
      while (i--) {
        bullets[i].className = ' ';
      }
      bullets[pos].className = 'on';

    }
});
<div id="slider" data-role="page">
    <div data-role="content" id="contentSlider">
        <div id='mySwipe' style='min-width:500px; margin:0 auto' class='swipe'>
            <div class='swipe-wrap'>
                <div><b>1</b>
                </div>
                <div><b>2</b>
                </div>
                <div><b>3</b>
                </div>
            </div>
        </div>
        <div style='text-align:center;padding-top:20px;'>
            <button onclick='mySwipe.prev()'>prev</button>
            <button onclick='mySwipe.next()'>next</button>
        </div>
    </div>
    <nav data-theme="a" data-role="footer" data-position="fixed" id="footer">
        <ul id='position'>
            <li class='on'></li>
            <li></li>
            <li></li>
        </ul>       
    </nav>    
</div>
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, del, dfn, em, img, ins, kbd, q, samp, small, strong, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, table, tbody, tfoot, thead, tr, th, td, article, aside, footer, header, nav, section {
  margin:0;
  padding:0;
  border:0;
  outline:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}
body {
  -webkit-text-size-adjust:none;
  font-family:sans-serif;
  min-height:416px;
}
h1 {
  font-size:33px;
  margin:50px 0 15px;
  text-align:center;
  color:#212121;
}
h2 {
  font-size:14px;
  font-weight:bold;
  color:#3c3c3c;
  margin:20px 10px 10px;
}
small {
  margin:0 10px 30px;
  display:block;
  font-size:12px;
}
a {
  margin:0 0 0 10px;
  font-size:12px;
  color:#3c3c3c;
}
.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
  width:80%;
}
.swipe-wrap > div {
  float:left;
  width:100%;
  position: relative;
}


html, body {
  background: #f3f3f3;
}

#console {
  font-size: 12px;
  font-family:"Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
  color: #999;
  line-height: 18px;
  margin-top: 20px;
  max-height: 150px;
  overflow: auto;
}

#mySwipe div b {
  display:block;
  font-weight:bold;
  color:#14ADE5;
  font-size:20px;
  text-align:center;
  margin:10px;
  padding:100px 10px;
  box-shadow: 0 1px #EBEBEB;
  background: #fff;
  border-radius: 3px;
  border: 1px solid;
  border-color: #E5E5E5 #D3D3D3 #B9C1C6;
}


#footer {
    height: 50px;
}

#position {
    margin-left: auto;
    margin-right: auto;   
    width: 60px;
}

#position li {
    display:inline-block;
    width:10px;
    height:10px;
    border-radius:10px;
    background:#141414;
    box-shadow:inset 0 1px 3px black,0 0 1px 1px #202020;
    margin:0 2px;
    cursor:pointer;
}

#position li.on{
    box-shadow:inset 0 1px 3px -1px #28b4ea,0 1px 2px rgba(0,0,0,.5);
    background-color:#1293dc;
    background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#1293dc),color-stop(100%,#0f6297));
    background-image:-webkit-linear-gradient(top,#1293dc,#0f6297);
    background-image:-moz-linear-gradient(top,#1293dc,#0f6297);
    background-image:-ms-linear-gradient(top,#1293dc,#0f6297);
    background-image:-o-linear-gradient(top,#1293dc,#0f6297);
    background-image:linear-gradient(top,#1293dc,#0f6297);
}
HTML:

var elem = document.getElementById('mySwipe');
var bullets = document.getElementById('position').getElementsByTagName('li');

window.mySwipe = Swipe(elem, {
    continuous: true,
    callback: function(pos) {      
      var i = bullets.length;
      while (i--) {
        bullets[i].className = ' ';
      }
      bullets[pos].className = 'on';

    }
});
<div id="slider" data-role="page">
    <div data-role="content" id="contentSlider">
        <div id='mySwipe' style='min-width:500px; margin:0 auto' class='swipe'>
            <div class='swipe-wrap'>
                <div><b>1</b>
                </div>
                <div><b>2</b>
                </div>
                <div><b>3</b>
                </div>
            </div>
        </div>
        <div style='text-align:center;padding-top:20px;'>
            <button onclick='mySwipe.prev()'>prev</button>
            <button onclick='mySwipe.next()'>next</button>
        </div>
    </div>
    <nav data-theme="a" data-role="footer" data-position="fixed" id="footer">
        <ul id='position'>
            <li class='on'></li>
            <li></li>
            <li></li>
        </ul>       
    </nav>    
</div>
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, del, dfn, em, img, ins, kbd, q, samp, small, strong, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, table, tbody, tfoot, thead, tr, th, td, article, aside, footer, header, nav, section {
  margin:0;
  padding:0;
  border:0;
  outline:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}
body {
  -webkit-text-size-adjust:none;
  font-family:sans-serif;
  min-height:416px;
}
h1 {
  font-size:33px;
  margin:50px 0 15px;
  text-align:center;
  color:#212121;
}
h2 {
  font-size:14px;
  font-weight:bold;
  color:#3c3c3c;
  margin:20px 10px 10px;
}
small {
  margin:0 10px 30px;
  display:block;
  font-size:12px;
}
a {
  margin:0 0 0 10px;
  font-size:12px;
  color:#3c3c3c;
}
.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
  width:80%;
}
.swipe-wrap > div {
  float:left;
  width:100%;
  position: relative;
}


html, body {
  background: #f3f3f3;
}

#console {
  font-size: 12px;
  font-family:"Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
  color: #999;
  line-height: 18px;
  margin-top: 20px;
  max-height: 150px;
  overflow: auto;
}

#mySwipe div b {
  display:block;
  font-weight:bold;
  color:#14ADE5;
  font-size:20px;
  text-align:center;
  margin:10px;
  padding:100px 10px;
  box-shadow: 0 1px #EBEBEB;
  background: #fff;
  border-radius: 3px;
  border: 1px solid;
  border-color: #E5E5E5 #D3D3D3 #B9C1C6;
}


#footer {
    height: 50px;
}

#position {
    margin-left: auto;
    margin-right: auto;   
    width: 60px;
}

#position li {
    display:inline-block;
    width:10px;
    height:10px;
    border-radius:10px;
    background:#141414;
    box-shadow:inset 0 1px 3px black,0 0 1px 1px #202020;
    margin:0 2px;
    cursor:pointer;
}

#position li.on{
    box-shadow:inset 0 1px 3px -1px #28b4ea,0 1px 2px rgba(0,0,0,.5);
    background-color:#1293dc;
    background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#1293dc),color-stop(100%,#0f6297));
    background-image:-webkit-linear-gradient(top,#1293dc,#0f6297);
    background-image:-moz-linear-gradient(top,#1293dc,#0f6297);
    background-image:-ms-linear-gradient(top,#1293dc,#0f6297);
    background-image:-o-linear-gradient(top,#1293dc,#0f6297);
    background-image:linear-gradient(top,#1293dc,#0f6297);
}
工作示例:

Javascript:

var elem = document.getElementById('mySwipe');
var bullets = document.getElementById('position').getElementsByTagName('li');

window.mySwipe = Swipe(elem, {
    continuous: true,
    callback: function(pos) {      
      var i = bullets.length;
      while (i--) {
        bullets[i].className = ' ';
      }
      bullets[pos].className = 'on';

    }
});
<div id="slider" data-role="page">
    <div data-role="content" id="contentSlider">
        <div id='mySwipe' style='min-width:500px; margin:0 auto' class='swipe'>
            <div class='swipe-wrap'>
                <div><b>1</b>
                </div>
                <div><b>2</b>
                </div>
                <div><b>3</b>
                </div>
            </div>
        </div>
        <div style='text-align:center;padding-top:20px;'>
            <button onclick='mySwipe.prev()'>prev</button>
            <button onclick='mySwipe.next()'>next</button>
        </div>
    </div>
    <nav data-theme="a" data-role="footer" data-position="fixed" id="footer">
        <ul id='position'>
            <li class='on'></li>
            <li></li>
            <li></li>
        </ul>       
    </nav>    
</div>
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, del, dfn, em, img, ins, kbd, q, samp, small, strong, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, table, tbody, tfoot, thead, tr, th, td, article, aside, footer, header, nav, section {
  margin:0;
  padding:0;
  border:0;
  outline:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}
body {
  -webkit-text-size-adjust:none;
  font-family:sans-serif;
  min-height:416px;
}
h1 {
  font-size:33px;
  margin:50px 0 15px;
  text-align:center;
  color:#212121;
}
h2 {
  font-size:14px;
  font-weight:bold;
  color:#3c3c3c;
  margin:20px 10px 10px;
}
small {
  margin:0 10px 30px;
  display:block;
  font-size:12px;
}
a {
  margin:0 0 0 10px;
  font-size:12px;
  color:#3c3c3c;
}
.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
  width:80%;
}
.swipe-wrap > div {
  float:left;
  width:100%;
  position: relative;
}


html, body {
  background: #f3f3f3;
}

#console {
  font-size: 12px;
  font-family:"Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
  color: #999;
  line-height: 18px;
  margin-top: 20px;
  max-height: 150px;
  overflow: auto;
}

#mySwipe div b {
  display:block;
  font-weight:bold;
  color:#14ADE5;
  font-size:20px;
  text-align:center;
  margin:10px;
  padding:100px 10px;
  box-shadow: 0 1px #EBEBEB;
  background: #fff;
  border-radius: 3px;
  border: 1px solid;
  border-color: #E5E5E5 #D3D3D3 #B9C1C6;
}


#footer {
    height: 50px;
}

#position {
    margin-left: auto;
    margin-right: auto;   
    width: 60px;
}

#position li {
    display:inline-block;
    width:10px;
    height:10px;
    border-radius:10px;
    background:#141414;
    box-shadow:inset 0 1px 3px black,0 0 1px 1px #202020;
    margin:0 2px;
    cursor:pointer;
}

#position li.on{
    box-shadow:inset 0 1px 3px -1px #28b4ea,0 1px 2px rgba(0,0,0,.5);
    background-color:#1293dc;
    background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#1293dc),color-stop(100%,#0f6297));
    background-image:-webkit-linear-gradient(top,#1293dc,#0f6297);
    background-image:-moz-linear-gradient(top,#1293dc,#0f6297);
    background-image:-ms-linear-gradient(top,#1293dc,#0f6297);
    background-image:-o-linear-gradient(top,#1293dc,#0f6297);
    background-image:linear-gradient(top,#1293dc,#0f6297);
}
HTML:

var elem = document.getElementById('mySwipe');
var bullets = document.getElementById('position').getElementsByTagName('li');

window.mySwipe = Swipe(elem, {
    continuous: true,
    callback: function(pos) {      
      var i = bullets.length;
      while (i--) {
        bullets[i].className = ' ';
      }
      bullets[pos].className = 'on';

    }
});
<div id="slider" data-role="page">
    <div data-role="content" id="contentSlider">
        <div id='mySwipe' style='min-width:500px; margin:0 auto' class='swipe'>
            <div class='swipe-wrap'>
                <div><b>1</b>
                </div>
                <div><b>2</b>
                </div>
                <div><b>3</b>
                </div>
            </div>
        </div>
        <div style='text-align:center;padding-top:20px;'>
            <button onclick='mySwipe.prev()'>prev</button>
            <button onclick='mySwipe.next()'>next</button>
        </div>
    </div>
    <nav data-theme="a" data-role="footer" data-position="fixed" id="footer">
        <ul id='position'>
            <li class='on'></li>
            <li></li>
            <li></li>
        </ul>       
    </nav>    
</div>
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, del, dfn, em, img, ins, kbd, q, samp, small, strong, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, table, tbody, tfoot, thead, tr, th, td, article, aside, footer, header, nav, section {
  margin:0;
  padding:0;
  border:0;
  outline:0;
  font-size:100%;
  vertical-align:baseline;
  background:transparent;
}
body {
  -webkit-text-size-adjust:none;
  font-family:sans-serif;
  min-height:416px;
}
h1 {
  font-size:33px;
  margin:50px 0 15px;
  text-align:center;
  color:#212121;
}
h2 {
  font-size:14px;
  font-weight:bold;
  color:#3c3c3c;
  margin:20px 10px 10px;
}
small {
  margin:0 10px 30px;
  display:block;
  font-size:12px;
}
a {
  margin:0 0 0 10px;
  font-size:12px;
  color:#3c3c3c;
}
.swipe {
  overflow: hidden;
  visibility: hidden;
  position: relative;
}
.swipe-wrap {
  overflow: hidden;
  position: relative;
  width:80%;
}
.swipe-wrap > div {
  float:left;
  width:100%;
  position: relative;
}


html, body {
  background: #f3f3f3;
}

#console {
  font-size: 12px;
  font-family:"Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
  color: #999;
  line-height: 18px;
  margin-top: 20px;
  max-height: 150px;
  overflow: auto;
}

#mySwipe div b {
  display:block;
  font-weight:bold;
  color:#14ADE5;
  font-size:20px;
  text-align:center;
  margin:10px;
  padding:100px 10px;
  box-shadow: 0 1px #EBEBEB;
  background: #fff;
  border-radius: 3px;
  border: 1px solid;
  border-color: #E5E5E5 #D3D3D3 #B9C1C6;
}


#footer {
    height: 50px;
}

#position {
    margin-left: auto;
    margin-right: auto;   
    width: 60px;
}

#position li {
    display:inline-block;
    width:10px;
    height:10px;
    border-radius:10px;
    background:#141414;
    box-shadow:inset 0 1px 3px black,0 0 1px 1px #202020;
    margin:0 2px;
    cursor:pointer;
}

#position li.on{
    box-shadow:inset 0 1px 3px -1px #28b4ea,0 1px 2px rgba(0,0,0,.5);
    background-color:#1293dc;
    background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#1293dc),color-stop(100%,#0f6297));
    background-image:-webkit-linear-gradient(top,#1293dc,#0f6297);
    background-image:-moz-linear-gradient(top,#1293dc,#0f6297);
    background-image:-ms-linear-gradient(top,#1293dc,#0f6297);
    background-image:-o-linear-gradient(top,#1293dc,#0f6297);
    background-image:linear-gradient(top,#1293dc,#0f6297);
}

仅供参考,以下答案几乎完全从swipejs主页中删除;Firebug/Chrome开发工具是您的朋友;)右键单击,检查元素并查看相关的css和js.FYI,下面的答案几乎完全来自swipejs主页;Firebug/Chrome开发工具是您的朋友;)右键单击,检查元素并签出关联的css和js。JSFIDLE在我这方面不起作用。有人确认吗?JSFIDLE在我这边不起作用。有人确认吗?