Form to Link 1.0

Created Thursday 1st of January 1970 by Andreas Lagerkvist
Copyright © 2010 Andreas Lagerkvist (andreaslagerkvist.com)

What it Does

Run this plug-in on a form or an input[type=submit] and it will insert a link after the element you run it on which, on click, will submit said form.

How to Use

jQuery('#post-comment input[type=submit]').formToLink();

Example

Example Code

HTML

<div id="jquery-form-to-link-example">
<
form method="post" action="">
    <
p>
        <
input type="submit" value="Delete comment"/>
    </
p>
</
form>
</
div>

JS

jQuery('#jquery-form-to-link-example form').formToLink();

Source Code

jQuery.fn.formToLink = function (c) {
    var 
cls || 'jquery-form-to-link';

    return 
this.each(function () {
        var 
t        = $(this);
        var 
form    t.is('form') ? t.parents('form').eq(0);
        var 
input    t.is('input') ? t.find('input[type=submit]');

        $(
'<a href="#" class="' cls '">' input.val() + '</a>').insertAfter(t).click(function () {
            
form.submit();

            return 
false;
        });
    });
};

Download

Plug-in

Requires

blog comments powered by Disqus

Random jQuery Plug-ins

  • Center

    This little pluggy centers an element on the screen using either fixed or absolute positioning. Can be used to display messages, pop up images etc.

    Details

  • Favicons

    This little plug-in will insert favicons to all external links found on your site. The plug-in scans the URL the link is pointing to for a favicon and...

    Details

  • Pixastic Editor

    This app/plug-in inserts a (completely stylable) toolbar next to any image in your document that allows the user to apply different Pixastic-effects ...

    Details

More Plug-ins

Recent Comments

Powered by Disqus
Page cached. Loaded in: 0.0169 second(s).
Last DB change: 2012-04-02 11:06:05
Last file change: 2012-04-25 20:30:39
Cache created: 2012-05-18 06:36:42