当我点击课程(.device_phone_apple_x)时,需要在此下拉列表中选择值1.
<select class="bookly-select-mobile bookly-js-select-service">
<option value="">Select model</option>
<option value="1">iPhone X</option>
<option value="2">iPhone 8</option>
<option value="3">iPhone 8+</option>
</select>
此下拉列表中的值1也需要处于活动状态。
$(function() {
$('.device_phone_apple_x').click(function(){
$('.bookly-select-mobile bookly-js-select-category').val(1);
$('.bookly-select-mobile bookly-js-select-service').val(1);
<script type="text/javascript">
// This is where the row with models show up
$(".device_phone").click(function(){
document.getElementById('device_choice').style.display='none';
document.getElementById('device_phone_brand').style.display='block';
});
// This is the stage where the row with the form does pop up
$(".device_phone_brand_apple").click(function(){
document.getElementById('device_phone_brand').style.display='none';
document.getElementById('device_phone_models_apple').style.display='block';
});
// Reload page
$("#annuleren_button").click(function(){window.location.reload();});
如何帮助我制作JS代码? Cuz似乎没什么用的!?
我现在有这个。
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: _site/index.html
upload: _site/index.html
- url: /assets
static_dir: _site/assets
# index files
- url: /(.+)/
static_files: _site/\1/index.html
upload: _site/(.+)/index.html
- url: /(.*)
static_files: _site/\1
upload: _site/(.*)
- url: /.*
static_dir: _site
答案 0 :(得分:1)
问题在于你的jQuery选择器。尝试修改为:
$(function() {
$('.device_phone_apple_x').click(function(){
$('.bookly-select-mobile.bookly-js-select-category').val(1);
$('.bookly-select-mobile.bookly-js-select-service').val(1);
答案 1 :(得分:0)
你的意思是这样吗?
<button class="device_phone_apple_x">Apple X</button>
<select class="bookly-select-mobile bookly-js-select-category">
<option value="">Select brand</option>
<option value="1">Apple</option>
<option value="2">Samsung</option>
<option value="0">No category</option>
</select>
<select class="bookly-select-mobile bookly-js-select-service">
<option value="">Select model</option>
<option value="1">iPhone X</option>
<option value="2">iPhone 8</option>
<option value="3">iPhone 8+</option>
</select>
<script>
const button = document.querySelector('.device_phone_apple_x')
const selectCategory = document.querySelector('.bookly-js-select-category')
const selectService = document.querySelector('.bookly-js-select-service')
button.addEventListener('click', () => {
const value = 1
selectCategory.value = value
selectService.value = value
})
</script>
答案 2 :(得分:0)
工作的人!谢谢!
<script type="text/javascript">
jQuery(document).ready(function($){
$(".device_phone_apple_x").click(function(){
document.getElementById('device_phone_models_apple').style.display='none';
document.getElementById('progress').style.display='none';
document.getElementById('bookly_row1').style.display='block';
$('.bookly-select-mobile.bookly-js-select-category').val(1);
$('.bookly-select-mobile.bookly-js-select-service').val(1);
$('.bookly-next-step.bookly-js-next-step.bookly-btn.ladda-button').trigger('click');
});
});