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

  • Home
  • SEARCH
  • 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 6532595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:01:26+00:00 2026-05-25T10:01:26+00:00

I am trying to copy text from list item in unordered list to a

  • 0

I am trying to copy text from list item in unordered list to a text box.

<div class='this_section_is_created_dynamically_and_repeats_up_to_99_times'>
<label>Serial</label>
<input name="part" class= "part" type="text">
<ul>
    <li class="pattern"><a href="#" class="clickme">test1</a></li>
    <li class="pattern"><a href="#" class="clickme">test2</a></li>
</ul> 

<script>

$('.clickme').live('click', function() {                

            alert($(this).text());  // this works
        // try to copy value clicked to input box. these do not work
        $(this).prevAll('[input:text]').val($(this).text()); 
        $(this).prev(":text").val($(this).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-05-25T10:01:27+00:00Added an answer on May 25, 2026 at 10:01 am

    prev() and prevAll() look at siblings. The input is a sibling of your ul which is the parent of your lis which are the parents of your anchors:

    These should work:

    $(this).parent().parent().prev("input:text").val($(this).text());
    

    Or:

    $(this).parents('ul').first().prev('input:text').val($(this).text());
    

    You could also give your input an id and just select it directly rather than traversing the DOM.

    PS. You should close your input tag: <input name="part" class= "part" type="text" />

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

Sidebar

Related Questions

i have been trying to copy text input from alertview textfield to a NSMutableArray
I'm trying to create a singly linked list from an input text file for
I'm trying to create an inventory list (tab-delimited text, for the output) from XML
I'm trying to grab the text from options in a dropdown list. Assume that
I am trying to create a simple js script that will copy text from
I'm basically trying to create a linked list from a text file and add
I'm trying to get a pyside button to copy text from a qlineEdit field
I'm trying to copy both an image from a file and text from a
Trying to copy some user input from one HTML input to another and my
I need to copy the strings from text box to struct. is there any

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.