Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

jQuery Help - On Change of Select show div

<select class="form-control" name="assetType" required="" style="padding:0;">
                                <option value="" disabled="">---</option>
                                                                    <option value="1">TEXT</option>
                                                                        <option value="2">VIDEO</option>
                                                                        <option value="3">IMAGE</option>
                                                                        <option value="4">BILLBOARD</option>
                                                                        <option value="5">BANNER</option>
                                                                        <option value="6">OTHER</option>
                                                                </select>

Open in new window


How can I look for a change event of the dropdown and show a div only if the "VIDEO" selection is selected?
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you want to select on the actual text of the option then replace line 25 with
    if ($('option:selected', this).text() ==  'VIDEO')

Open in new window

Hi,
this should do the trick:
$("select[name='assetType']").change(function() {
	if ($(this).val() == 2) {
		$("#YourdDIVid").show();
	}
});

Open in new window

HTH
Rainer
Please ignore my double posting - Julians answer is the one you should choose (too late 4 me :-)