var item='<input class="item" type="text" value="1"/>';
$('#div1').replaceWith(item);
var val1 = $('.item').val();
This returns undefined.I think it has something to do with replacing the DOM element but I don’t know how to fix this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Seems to work for me:
http://jsfiddle.net/YMBeX/
I suspect that you have an issue somewhere else in your code.