I have one condition where I want to add text area when I select any option from select option. I have 4 to 5 options in my select box and I want one text area to be added when I select any option from my select box.
Here is my html:
<select name="menu-114" class="wpcf7-form-control wpcf7-select" aria-invalid="false">
<option value="Select Category" selected="selected">Select Agent Name</option>
<option value="Option 1">Mr. abc</option>
<option value="Option 2">Mr. abc</option>
<option value="Option 3">Mr. abc</option>
</select>
<textarea></textarea>
I want to add the textarea when I select any option from above select box.
See my fiddle
I can't think why you would want to but here's how I would do it:
Listen for the change
event on your select
element and use $.appendTo
$(document).on('change', 'select[name=menu-114]', function(){
$("<textarea>").appendTo(".agent_select_wrap");
//$(this).val() will return the value attribute of the select
});
Here's a working fiddle
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments