Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8028673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:11:55+00:00 2026-06-05T00:11:55+00:00

I am trying to adapt this script: jQuery Example: Inserting text with drag n’

  • 0

I am trying to adapt this script: jQuery Example: Inserting text with drag n’ drop.

The goal is for my users to click an image thumbnail and have the appropriate markdown image code inserted into the textarea.

I am not familiar with JS, so I am aware that the meat of the script is happening here:

$('#ClickWordList li').click(function() {
    $("#txtMessage").insertAtCaret($(this).text());
        return false
    });

specifically, the .text() bit there, but do not know how to alter the output to suit my needs for a snippet of markdown being inserted rather than just, say, the list text.

Markdown inline image syntax looks like this: ![Alt text](/path/to/img.jpg)

I tried changing the list to a div with images and then changing to .insertAtCaret($(this).src); but I get “undefined” as the insertion text.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T00:11:56+00:00Added an answer on June 5, 2026 at 12:11 am

    $(this).src is undefined because $(this) is a jQuery object, and jQuery objects don’t have a src property. Assuming you have an image element in your selector, You can try:

    $("#txtMessage").insertAtCaret($(this).attr('src'));
    

    The .attr() jQuery method, when given only one parameter, will return the matched element’s given attribute’s value.

    or

    $("#txtMessage").insertAtCaret($(this)[0].src);
    

    To get the literal DOM element’s src.

    Extra explanations (if you need)
    The .text() jQuery method, when given no parameters, will return all text inside of the element referenced by this, that is, the event’s target, in this case the clicked li inside the #ClickWordList element.

    .insertAtCaret() is an extended function of the jQuery object provided by your drag 'n drop plugin.

    return false will do exactly what it says, returning false in the click event’s handler for the selected element, which simply cancels the event and prevents its propagation from bubbling up the DOM further.

    Sorry if there are any typos.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to adapt this DES encrypting example to AES, so I made the
I'm trying to adapt this defstruct example by adding the select- functions described in
So I'm trying to adapt this Dropdown menu on Joomla the styles work great
I'm trying to adapt a VBscript that runs the QWINSTA command against a text
I'm trying to adapt this python code I found for connecting to the Dropbox
I'm trying to adapt Andy Langton's show/hide/mini-accordion ( http://andylangton.co.uk/jquery-show-hide ) to work within a
I'm trying to adapt a jquery-ui codebase to use RequireJs, and I'm deploying it
This is a mailing list script. It works by itself without jquery but I
I'm trying to use this fixed floating banner script in IE6 -> Demo According
Im trying to adapt some code that I have found online that uses this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.