Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Add item to where the Cursor Text

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #28126
    asp
    Participant

    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)
  • The forum ‘JavaScript’ is closed to new topics and replies.