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>
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.
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.
精彩评论