javascript - Jquery更改iframe选择选项文本
问题描述
更改 iframe 选择选项文本不起作用,我不知道为什么。JSFiddle
第一个代码块更改选择选项成功
//when page loads
setTimeout(function() {
var iframePreLoad = $("#product-component-1631134480393").children().contents();
iframePreLoad.find(".shopify-buy__option-select__select").ready(function(){
iframePreLoad.find('select[name=Color] option:nth-child(1)').html('Black');
iframePreLoad.find('select[name=Color] option:nth-child(2)').html('Green');
});
}, 3000);
第二个代码块应该在与选择框交互时更改文本。Example when one of the options are selected, the text for both options should change but it's not working.
//When selection is made
$("#product-component-1631134480393").on('load', function() {
$("#product-component-1631134480393").children().contents().find("select[name=Color]").on('change', function() {
$('select[name=Color] option:nth-child(1)').html('Black');
$('select[name=Color] option:nth-child(2)').html('Green');
console.log('selection changed');
});
});
解决方案
推荐阅读
- netlify - 部署卡在生产上传 Netlify
- php - Laravel date_format 验证在文本月份失败
- c++ - ncurses 检测鼠标何时离开窗口
- tensorflow - tensorflow.python.framework.errors_impl.DataLossError:校验和不匹配
- vim - VIM:删除不均匀缩进的多行的前 x 个非空格字符
- javascript - 更新商店时我的组件不会重新渲染
- ssrs-2008 - 如何按降序对 SSRS 表列组进行排序?
- javascript - 如果参数不为空,则返回值
- c# - C#:如何使用 google.apis.drive.v3 将文件上传到 Google Drive
- symfony-forms - 如何修复“尝试调用名为“createNamedBuilder ...”的未定义方法?