javascript - Custom option values depending on the screen size -
the below being used in page.
<script id="score" type="text/template"> <select name="scoreselector"> <option value="" disabled selected>your score</option> <option value="0.25">quarter</option> <option value="0.50">half</option> <option value="0.75">three quarter</option> </select> </script>
how can set value of each option depending on screen width?
example
var width = $(window).width(); if (width <= 1023) { //set <option value="0.25">quarter</option> } else { //set <option value="0.35">quarter</option> }
you may :
var width = $(window).width(); if (width <= 1023) { $('select[name=scoreselector]').val('0.25'); } else { // etc. }
Comments
Post a Comment