jquery - dynamically change the name attribute of an element -


i have jquery function takes following html page using this:

//get html var myhtml = $("#info").html() 

here's html gets:

    <div id="info">         <table>             <tr>                 <td><input type="text" name="tbanswer" value="feedback..." /></td>             </tr>         </table>     </div> 

i'm trying change name of textbox name attribute follow counter. name="tbanswer1"

i tried this:

$(document).on('ready', function () {     $("info").closest("input").attr("name", "tbanswer" + mycounter); }); 

but it's not finding it.

is there way of doing jquery?

thanks!

you forgot #:

$("#info").find("input").attr("name", "tbanswer" + mycounter); 

and want find, not closest. find gets descendants, input is.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -