简体   繁体   中英

Jquery functions more than once on the same page

I'm new self learning to used Jquery functions and i have no ideas how to do the following.

How do i used the following script to apply to more that one div id on the same page?

<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript" src="/jquery.form.js"></script>
<script type="text/javascript" src="/jquery.validate.js"></script>
<script type="text/javascript">
    $('document').ready(function()
    {

      $('#memberslinkupform').ajaxForm( {
        target: '#memberslinkup', 
        success: function() { 
          $('#formbox').slideUp('fast'); 
        } 
      }); 
    });
</script>

You can give your <div> elements a "class" value and then:

  $('div.your-class-name').ajaxForm({ ... });

Note that the jQuery "form" plugin is kind-of old, and with modern versions of jQuery it's hard to find reasons to use it.

Add another ID in your selector like so

$('#memberslinkupform,#anotherId').ajaxForm({ ...})

A comma between the 2 items you wish to select. Adding a class is one option as well and then attaching the class to both the forms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM