Jump to content

jquery html() for inputs


V

Recommended Posts

I'm using the jquery html() function to add some text into a textarea but it doesn't work with inputs.

 

The working js is,

 

$('.edit').click(function()
{
var unique_id = $(this).attr("id"); //get unique ID from .edit link
var some_text = $('.some_text'+unique_id+'').html(); //get html from class with id=unique_id
$('.some_input'+unique_id+'').html(some_text); //add html to textarea with id=unique_id
});

 

 

And the HTML.. I'm using unique numbers for each group to edit them individually.

 

<a href="#" class="edit" id="1">Edit</a>
<div class="some_text1">Content here</div>
<textarea class="some_input1"></textarea>

<a href="#" class="edit" id="2">Edit</a>
<div class="some_text2">Content here</div>
<textarea class="some_input2"></textarea>

<a href="#" class="edit" id="3">Edit</a>
<div class="some_text3">Content here</div>
<textarea class="some_input3"></textarea>

 

Everything above works fine with textarea but when I change it to "input type="text" no html is added into the input. For example,

 

<input type="text"  class="some_input3" />

 

Is there any way of passing html() to inputs?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.