0

下面是我的代码,除了将滑块动态链接到每个输入字段外,我一切正常。这是我的实时页面

<?php $dirname="panos/" ; $images=g lob($dirname. "*.jpg");
foreach($images as $image) {
    $imageName=s ubstr($image, -14); echo '
    <img src="resize.php?w=450&amp;img='.$image. '" />
    <input    id="'.$imageName. '-slider"/>
    <br />
    <div style="width:450px" id="'.$imageName. '" class="slider"></div>
'; } ?>
<script>
    $(function () {
        $(".slider").each(function () {
            $(this).slider({
                value: 0,
                min: 0,
                max: 360,
                step: 1,
                stop: function (event, ui) {
                   var v = $(this).attr('id')
                   var n = $(this).slider('value')
                   $("#" + v + "-slider").val(n);
                   window.alert(v)
               },
               create: function (event, ui) {
                   var v = $(this).attr('name')
                   var n = $(this).slider('value')
                   $("#" + v + "-slider").val('0');
               }
           });
       })
    });
</script>
4

1 回答 1

0

FIGURED IT OUT!!! The files that was getting pulled by the PHP had ".jpg" in the middle of it! And even tho it is a valid ID name it ended up messing up the jquery portion of it! I just did this

$imageNameLong = substr($image, -14);
$imageName = substr($imageNameLong,0 , -4);

and took off that ".jpg" and now it works flawlessly!!!

于 2013-03-06T23:59:55.443 回答