I have this PHP/Jquery/JqueryUI loop script which makes a range of elements draggable by id and it works fine:-

```
<?php
  $phpid=1;
  while($phpid < 10){
    <script>
      $(function(){$('#<?php echo $phpid ?>').draggable()});
    </script>
  $phpid++;
  }
?>

```

However I need to change it from PHP to Javascript/Jquery/JqueryIU script only. The first thought is:-

```
<script>
  var scriptid=1;
  while (scriptid < 10){
    $(function(){$('#scriptid').draggable()});
  scriptid++;
</script>

```

But this won't work as `scriptid` is inside quotes, so I try:-

```
$(function(){$('#'+scriptid).draggable()});

```

This works but only on the very last element. It's like it's performing the loop counting `scripted` up to 10 then performing the function. I can:-

```
$(function(){$('#'+1).draggable()});
$(function(){$('#'+2).draggable()});
$(function(){$('#'+3).draggable()});
.
.
$(function(){$('#'+10).draggable()});

```

This works fine but I need it to be in a loop. I know the `$(function(){ ..... })` waits for the page to load before executing but dropping it off just gives syntax error.

I think this has a simple, neat solution (possibly using `.each` or `this`) but it's become a time waster for me now. Any ideas thanks?