Grow your CSS skills. Land your dream job.

Add item to where the Cursor Text

  • asp
    # February 24, 2010 at 1:52 pm

    Hi

    I got a jQuery code that adds links and other stuff to a textfield. But I was wondering if I could add add stuff to where the Cursor Text is.

    Is this posible and how?

    Here is the code.

    Code:
    $(document).ready(function(){
    $(‘.add’).click(function () {

    var $textarea = $(‘#innhold’),
    start = ‘‘;

    value = $textarea.val(),

    append_text = $(this).attr(‘value’),
    append_type = $(‘#class’).attr(‘value’),

    space = ‘ ‘;

    type = ‘” class=”‘;

    if( value == ” )
    space = ”;

    $textarea.val(value + space + start + append_text + type + append_type + end);
    });
    });

    Thank you :D

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".