Select onchange doesnt work

夙愿已清 提交于 2019-12-25 07:27:43

问题


Anyone else has this problem that select doesn't work good in framework7?

After building apk file select sometimes needs to be changed twice to take effect.

What can cause it ? I removed all external files, and it's sill not working as it should.

<select id="random-select">
                            <option id="1">1</option>
                            <option id="2">2</option>
                            <option id="3">3</option>
                            <option id="4">4</option>
                            <option id="5">5</option>
                            <option id="6">6</option>
                        </select>

    $('#random-select').change(function(){
    alert($(this).val());
})

Code is simple as that for select. It's in jquery.


回答1:


This is not an issue with framework7,Actually webkit fast-click is not supported.I faced the same issue and resolved the problem by adding a simple class to select element class="no-fastclick",It will work properly. Another way is to add "fastclick:false" in app init.




回答2:


try this

$(document).ready(function(){
  
  $('#random-select').change(function()
	{
    alert($(this).val());
    
  });
    
  
});
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="random-select"  name="selectbox" >
                            <option id="1">1</option>
                            <option id="2">2</option>
                            <option id="3">3</option>
                            <option id="4">4</option>
                            <option id="5">5</option>
                            <option id="6">6</option>
                        </select>


来源:https://stackoverflow.com/questions/37520765/select-onchange-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!