Choosing item from dropdown menu with javascript
Hey I am trying to choose option from one site with javascript. No luck, I have tried couple of methods, but none seem to work. In this si开发者_Python百科te http://www.finnkino.fi/movies/maxim_helsinki there is dropdown menu which says Tänään, 13.11.2010. I need to change to to another value from the menu with javascript. Help is highly appericiated! Thanks!
Emulating the user's mouse clicks:
$('#dt_input').click();
$('#dt_input_14\\.11\\.2010').click();
Two backslashes are necessary before each dot because jQuery interprets the dot to refer to a specific HTML class; we need to escape the dots. Alternatively, use document.getElementById
, which doesn't require the dots to be escaped:
$(document.getElementById('dt_input_14.11.2010')).click();
You could set the value of the <select>
tag to some other value:
document.getElementById('dt').value = '08.01.2011';
This will select the option with value="08.01.2011"
.
Or using jquery:
$('#dt').val('08.01.2011');
精彩评论