实际上我在我的移动设备上开发了一个html5/php/css/javascript的web应用程序。(我是一个初学者)我有一个"点击"功能在我的"选项",但与本机选择设备的小部件,它不工作。可以禁用选择小部件吗?
<select class="theme" name="newtheme">
<option id="white" class="white" onclick="createCookie('theme','white',7)">white</option>
<option id="white" class="white" onclick="createCookie('theme','white',7)">white</option>
</select>
提前致谢
您可以使用jQuery:
$("#ThemeSelector").on('change', function(event){
// event contains the data from the selected line
createCookie('theme','white',7);
});
你的HTML应该是这样的:
<select id="ThemeSelector" class="theme" name="newtheme">
<option class="white">white</option>
<option class="white">white</option>
</select>
ID必须是唯一的!
在开发移动web应用程序时,你应该尽量避免使用"onClick",而应该使用"tap"事件。它们的性能更好,会让你的UI反应更快。(它们也会带来更少的麻烦——例如,在某些情况下,点击并不总是在不同的移动浏览器上触发)。
当然,@ robert使用"change"事件的建议也应该行得通。
我只是想指出,正如你所说,你是一个初学者。