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
https://forums.phpfreaks.com/topic/209312-jquery-html-for-inputs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.