javascript - How to remove all element from select option without first one using jquery -


this question has answer here:

i need 1 help. need remove element select option except first 1 using jquery/javascript.i explaining code below.

<select class="form-control" name="spacearea" id="spacestatusid" onchange="removeborder('spacestatusid');"> <option value="" selected>select space status</option> <option value="1">available</option> <option value="2">rented</option>  </select> 

from above need remove element within select tag except first 1 i.e-<option value="" selected>select space status</option> using jquery.please me.

here example. use .find() :gt()

$(function() {    $('#spacestatusid').find('option:gt(0)').remove();  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>    <select class="form-control" name="spacearea" id="spacestatusid" onchange="removeborder('spacestatusid');">    <option value="" selected>select space status</option>    <option value="1">available</option>    <option value="2">rented</option>  </select>


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -