$().ready(function()
{
$("#add").click(function()
{
var vals = $("#txtaddfeature").val();
if(vals !='')
$('#FeatureLists').prepend('<option value="' + vals + '" selected="selected">' + vals + '</option>');
$('#txtaddfeature').val('');
});
});
Ok after adding the value to the select list as above
$('#FeatureLists').prepend('<option value="' + vals + '" selected="selected">' + vals + '</option>');
I want to create a dynamic hidden field with id=vals defined above and set it value to value entered in the textbox . how can i do that
I couldn’t tell exactly what you wanted. It seems like you want both the
IDand thevalueof the new hiddeninputto be the value ofvals. Is that right?Then you would append it wherever you want.
EDIT:
For clarification,
selectoris the reference to the element where you want to append your new input.If you want to append it to the body tag, do:
If you want to append it to an element with the class
someClass, do: