Friday, December 28, 2012

onselect

Event handler onselect (Bubbles: No, Cancelable: Yes) terjadi ketika beberapa teks di dalam suatu elemen terseleksi.

Berikut contoh meregister event handler onselect via 'inline model':

<FORM> <INPUT TYPE="text" VALUE="Seleksi teks ini" ONSELECT="alert('Beberapa teks terseleksi')"> </FORM>

Berikut contoh meregister event handler onselect via 'traditional model':

<FORM> <INPUT TYPE="text" ID="inputTextID" VALUE="Seleksi teks ini"> </FORM> <SCRIPT TYPE="text/javascript"> function HandleEvent() { alert("Beberapa teks terseleksi"); } var inputElem=document.getElementById("inputTextID"); inputElem.onselect=HandleEvent; </SCRIPT>

Berikut contoh meregister event handler onselect via DOM:

<FORM> <INPUT TYPE="text" ID="inputTextID" VALUE="Seleksi teks ini"> </FORM> <SCRIPT TYPE="text/javascript"> function HandleEvent() { alert("Beberapa teks terseleksi"); } var inputElem=document.getElementById("inputTextID"); inputElem.addEventListener("select", HandleEvent, false); </SCRIPT>