I am loading a jQuery qtip on hover (as it usually works). Inside this qtip, there is a textbox and a button. On the click of this button, I want to do something with the value of this textbox. Somehow, jQuery's .val() function returns me the initial value of the textbox. Where am I going wrong?
jQuery code:
$(function() {
$("#someplace").qtip({
content: $("#popup"),
hide: {
fixed: true
},
position: {
corner: {
tooltip: 'topMiddle',
target: 'bottomMiddle'
},
adjust: {
x:-30,
y:-75
}
},
style: {
width:'100px',
color:'white',
name:'tspopup'
}
});
$("#button_in_the_qtip").click(
function () {
var txt = $("#textbox_in_the_qtip").val();
alert($("#textbox_in_the_qtip").attr('id')); // This returns "textbox_in_the_qtip"
alert(txt); // This returns "abc" <---- Problem
}
);
});
HTML code for the popup qtip:
<div style="display:none;" id="popup">
<table cellpadding="5px" border="1" style="margin-top:12px; margin-bottom:12px; color:#fff; font-size:.7em;">
<tr>
<td>
<input type="text" id="textbox_in_the_qtip" value="abc" />
</td>
<td>
<button id="button_in_the_qtip">Add</button>
</td>
</tr>
</table>
</div>