M?t v� d? ??n gi?n thay ??i m�u ch? c?a th? <p>. V� d? n�y s? d?ng m?t danh s�ch m�u t? th�nh ph?n <select>. V� ng??i d�ng ch? vi?c Ch?n m�u t? m?t Drop down list.?�y l� m?t v� d? ??n gi?n c?a DHTML, s? d?ng getElementById Method ?? l?y d? li?u t? m?t th�nh ph?n c�ng v?i id duy nh?t.
L?a ch?n m?t m�u ?? thay ??i m�u c?a d�ng ch? tr�n:
Source Code:
| <script language="javascript"> function changeTDColor(){ var selectOpt = document.getElementById('color'); var td = document.getElementById('content'); td.style.color = selectOpt.options[selectOpt.selectedIndex].value; } </script> <div id="content">?�y l� m?t v� d? ??n gi?n c?a DHTML, s? d?ng getElementById Method ?? l?y d? li?u t? m?t th�nh ph?n c�ng v?i id duy nh?t.</div> L?a ch?n m?t m�u ?? thay ??i m�u c?a d�ng ch? tr�n: <select name="color" id="color" onchange="changeTDColor()"> <option value="">?en <option value="#bc0fc1">H?ng <option value="#FF0000">?? <option value="#800000">?? ??m <option value="#0000FF">Xanh <option value="navy">Xanh ??m <option value="#00ff00">L� C�y <option value="#008000">L� C�y ??m </select> |
Đăng nhận xét