javascript - How to get the value of the first HTML option by default in jQuery? -
i'm using jquery 1.9.1 , jquery mobile 1.3.1, , have html this:
<p> how many days did menstrual cycle last? <select id="menstrualcycle" onclick="changefunc('menstrualcycle')"> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select> </p> then have js this:
function changefunc(select) { var selectbox = document.getelementbyid(select); var selectedvalue = selectbox.options[selectbox.selectedindex].value; if (select == 'monthcycle') { monthdays = selectedvalue; console.log("month value is: " + monthdays); } else if (select == 'menstrualcycle') { menstrualdays = selectedvalue; console.log("menstrual value is: " + menstrualdays); } else if (select == 'lutealphase') { lutealvalue = selectedvalue; console.log("luteal value is: " + lutealvalue); } } the point values, clicking options or selecting other options. when page open, page id "ovulinfopicker", defualt doesn't first values. want first values default, without changing values or pressing otions.
trigger alter event programmatically: http://api.jquery.com/trigger.
$('#id1, #id2, #id3').trigger('change'); you trigger event execute event handlers without actual user interaction.
javascript jquery html
No comments:
Post a Comment