javascript - How to remove the elements -


i need (under code can see need)

here code:

html

<input type="number" id="elementnr"> <button onclick="thefunction()">remove it</button> <p id="theelements"/> 

javascript

<script> var cars = ["bentley", "ferrari", "bmw", "mercedes", "lamborghini"]; document.getelementbyid("theelements").innerhtml = cars;  function thefunction() {      delete cars[3];     document.getelementbyid("theelements").innerhtml = cars;  } </script> 

right code when click button removes 3rd element(mercedes) because gave function wanted know if there's way edit code when type number 4 in textbox , click button removes 4th element or if type 2 on textbox , click button removes 2nd element etc.

very strange question... of course possible though. know how getelementbyid. can same input element , read value property, question remains. why want it...


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -