Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery : show div by dynamic id
- <ul>
- <li><a href="#" class="service-chooser" id="ubuntu-one">Ubuntu One</a></li>
- <li><a href="#" class="service-chooser" id="ftp">FTP account</a></li>
- </ul>
- <!-- these div are hidden -->
- <div id="ubuntu-one-form" class="hide">
- Ubuntu One credential
- </div>
- <div id="ftp-form" class="hide">
- Ftp Crediental
- </div>
- <script type="text/javascript">
- $(document).ready(function() {
- $(".service-chooser").click(function() {
- var service = $(this).attr('id');
- var service-id = '#' + service + 'form';
- $(service-id).show('slow', function() {
- // Animation complete.
- });
- });
- });
- </script>
- $(".service-chooser").click(function() {
- var service = this.id ; // Example ubuntu-one
- var service_id = '#' + service + '-form'; // Example #ubuntu-one-form
- $(service_id).show('slow', function() {
- // Animation complete.
- });
- });
- });
- $(".service-chooser").click(function() {
- var service = $(this).attr('id');
- var service_id = '#' + service + '-form';
Add Comment
Please, Sign In to add comment