Forums

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

Home Forums JavaScript Pulling text out of a P tag and putting it into a text area

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28706
    David Coxsey
    Member

    Okay, just used Chris’ snippet on making a div clickable. Now, I would like to take the text in my p tag and place it in a text area on my page. For example, here is my jQuery:

    Code:
    $(‘.displayAnswers’).click(function(){
    window.location =$(this).find(‘p.answer’);

    });

    Now, I want to take whatever is in a paragraph tag with the class of answer and place it into my text area. Is there a way to do this? I’m a jQuery noob, but I know I could do something like this using AJAX and .NET.

    #73834
    noahgelman
    Participant

    I think this should do it. The p tag at the beginning is the paragraph you want to target and inside the append is the opening and closing tags of your text area that you want to target. Tell me how it goes.

    Code:
    $(‘p’).text().clone().append(‘‘)
    #73843
    David Coxsey
    Member

    So, I tried that and nothing came of it. Here is the code I have now:

    Code:
    $(‘.displayAnswers’).click(function(){
    window.location = $(this).find(“p”).text();
    $(‘p’).text.clone().append(‘‘);
    });

    What happens when you click on this you get a 404 error. I tried it with out the second line, but then nothing happens on the site.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.