javascript - 在 Qualtrics 中更改 jQuery UI 对话框的宽度
问题描述
我正在编写 Qualtrics 中的调查。我想编写一个可点击的按钮,在框中显示一些文本。
我使用的代码是:
在 Qualtrics 调查标题中:
<link href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script src="//code.jquery.com/jquery-1.12.4.js"> </script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"> </script>
<script>
jQuery("[id*='dialog']" ).dialog({ autoOpen: false});
jQuery('body').on('click','.ui-widget-overlay',function(){ jQuery("[id*='dialog']").dialog('close'); });
</script>
JS中的具体问题:
Qualtrics.SurveyEngine.addOnload(function()
{
jQuery("#btn1").click(function() {
jQuery("#dialog").dialog( "option", "modal", true);
jQuery("#dialog").dialog( "open", "width", 500).css({
"padding":"0px"
});
})
});
问题文本中的 HTML:
<button id="btn1"> BUTTON TEXT </button><br>
<span title="MOD Explanation" id="dialog"> TEXT IN BOX</span>
但是,我无法更改框的宽度。我希望它以 450 像素的最小宽度在屏幕上传播约 60%。
谢谢你的帮助!
最好的,蒂姆
解决方案
评论解释了怎么做,不知道是什么Qualtrics.SurveyEngine.addOnload
,api在这里:https ://api.jqueryui.com/dialog/
$(document).ready(function() {
jQuery("#btn1").click(function() {
jQuery("#dialog").dialog({modal: true, width: "60%", minWidth: 450}); // you need to pass object here docs: https://api.jqueryui.com/dialog/
})
})
<html>
<head>
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<button id="btn1"> BUTTON TEXT </button><br>
<span title="MOD Explanation" id="dialog"> TEXT IN BOX</span>
</body>
</html>
推荐阅读
- azure - 部署为部署容器图像名称时如何激活 Web 应用程序中的设置
- macos - 当 Jupyter 内核中断时,M1 Macbook 崩溃
- php - 将 WooCommerce 属性表自定义为两列
- spss - SPSS 是否对时间相关的重复观察执行 cox 回归分析?
- javascript - 使用 Puppeteer 捕获可滚动页面中的所有链接 - 无限滚动
- reactjs - 如何使用 getStaticProps 进行重定向?
- windows - 批处理文件搜索与本地文件同名的文件夹并将所述文件移动到定位的文件夹不起作用
- markdown - 是否可以在 docusaurus v2 上禁用 JSX 验证?
- json - 插件命令的崇高键绑定
- javascript - 如果 Nock 按特定顺序运行多次测试,则不会拦截请求