jQuery是一个Javascript库,考虑添加Javascript标记。 jQuery是一个流行的跨浏览器JavaScript库,它通过最小化浏览器之间的差异来促进文档对象模型(DOM)遍历,事件处理,动画和AJAX交互。标记为jquery的问题应该与jquery相关,因此有问题的代码应该使用jquery,并且至少需要jquery与用法相关的元素。
下面是我的代码 超文本标记语言 下面是我的代码 HTML <div class="container"> <div class="row"> <div class="col-sm-12"> <div id="owl-demo"> <div class="item"><a href=""><img src="http://ppt.cc/1BbHy" alt="image-03.png"></a><p>123456789012345678901234567890123456789012345678901234567890</p></div> <div class="item"><a href=""><img src="http://ppt.cc/1BbHy" alt="image-03.png"></a><p>123456789012345678901234567890123456789012345678901234567890</p></div> <div class="item"><a href=""><img src="http://ppt.cc/1BbHy" alt="image-03.png"></a><p>123456789012345678901234567890</p></div> <div class="item"><a href=""><img src="http://ppt.cc/1BbHy" alt="image-03.png"></a><p>123456789012345678901234567890</p></div> <div class="item"><a href=""><img src="http://ppt.cc/1BbHy" alt="image-03.png"></a><p>123456789012345678901234567890</p></div> </div> </div> </div> CSS #owl-demo .item{ margin: 0px 5px 0px; } #owl-demo .item img{ display: block; width: 50%; height: auto; } Javascript $(document).ready(function() { $("#owl-demo").owlCarousel({ autoPlay: false, //Set AutoPlay to 3 seconds items : 5, itemsDesktop : [1024,5], itemsDesktopSmall : [979,3], navigation : true, pagination : false, navigationText : ["<", ">"] }); }); 我使用 owl-carousel 作为滑块,想在每个图像下添加一些文本或段落。Owl-carousel 支持滑块的响应式,那么如何将段落放在每个图像下并支持响应式设计呢? 这是我在 JSFIDDLE 上的代码 联邦法院系统通常存在于中央(联邦)政府与各个州或省之间权力划分的国家内。其管辖权由宪法条款和法规界定,定义了其可以审理和裁决的案件的具体类型。以下是对通常与联邦法院相关的司法管辖区的详细探讨:
单击按钮后我必须调用相同的函数但不起作用 关闭后 jQuery 函数触发事件不会被调用 如何在 jQuery 中调用 click 函数 请谁给我
如何在纯 HTML5/CSS/Jquery 中显示 epub 格式的书籍 [已关闭]
是否可以使用纯HTML5、CSS和Jquery在网络浏览器中显示epub格式的书籍?有人可以建议我该怎么做吗?我还必须使其响应才能使其...
JQuery - ajax 将数组发送到 Spring 控制器 - 错误请求
我正在使用Spring 5.3.9,jackson-core和jackson-databind-2.17.1版本。从 UI 中,我将 json 数组发送到控制器。我在控制器中尝试了多种参数类型,但没有......
我正在尝试使用 Jquery/AJAX/JSON 和 CFC 来发送电子邮件(很简单吧?)在花了很多时间试图找到一个完整的示例来说明它应该如何工作之后,我已经接近了,但被卡住了于...
我有一个反馈页面,看起来像这样(我只是每页显示 1 条评论,看看分页是否正常工作。否则我会显示更多): 反馈来自 mysql 数据库,并且是
我有一个自定义卡片复选框。如果它(卡复选框)是必需的并且未选中,我想将焦点和滚动到表单提交(表单正在使用 jQuery 验证进行验证)到此卡复选框。怎么...
大家好, 我有一个带有密码字段的表单: 当然,输入的文本将被替换为 (*)。 因此,如果用户输入 123 ...
我正在使用 Laravel 框架,希望在会话过期时创建警报。我尝试实现一个 JavaScript 代码,检查用户是否每三秒登录一次,如下...
我正在尝试使用带有 jQuery 的 AjaxQ 插件来对一些 ajax 请求进行排队,但无论我尝试什么,似乎都未定义。 出现以下错误: 类型错误:无法读取未定义的属性(
浏览器滚动放大或缩小是否会触发window.resize()?
浏览器中滚动放大或缩小是否会触发 jquery/jscript 的 window.resize() 事件? (当您按下控件并使用鼠标滚轮并聚焦浏览器窗口时) ED...
Kendo .showTooltip() 用于具有多个系列的圆环图
我正在使用配置为包含两个系列的甜甜圈的 jquery kendo 图表。我需要能够以编程方式突出显示一个部分并在第二个系列中显示其工具提示,模拟...
当在对话框中按“确定”时,服务器方法执行,如果按“取消”,则留在我的页面上。怎么办?
我想在我的 aspx 页面中使用对话框(确定和取消)。 当我按“确定”时,我的服务器端代码应该执行,当我按“取消”时,什么都不会发生,即使回发也应该...
我无法让下拉菜单动态显示标记为 style="display:none" 的 html 代码块。 我有以下代码。 $(\'选择...</desc> <question vote="4"> <p>我无法让下拉菜单动态显示标记为 <pre><code>style="display:none"</code></pre> 的 html 代码块。</p> <p>我有以下代码。</p> <pre><code><script type="text/javascript"> $(\'select[name="questiontype"]\').change(function(){ if ($(this).val() == "multiple") alert("call the do something function on option multiple"); else alert("call the do something function on option programming"); }); </script> <form action="addQuestion.php" method="post"> <select name="questiontype"> <option name="questiontype" value="multiple" click="return showMultiple();">Multiple Choice< /option> <option selected name="questiontype" value="programming" click="return showProgramming();">Programming< /option> </select><br> <input type="hidden" name="course" value="'.$course.'" /> <div id=\'multiple\' style="display:none"> Multiple </div> <div id=\'programming\' style="display:none"> Programming </div> </form> </code></pre> <p>我尝试了这些函数来 .show() 从下拉菜单中通过 id 来显示 div,但没有成功,我不确定我做错了什么。我还删除了 div id 块中的一些代码以使其更易于阅读。</p> <pre><code><script> function showMultiple(){ $('#multiple').show(); $('#programming').hide(); return false; } function showProgramming(){ $('#multiple').hide(); $('#programming').show(); return false; } </script> </code></pre> </question> <answer tick="true" vote="9"> <p><a href="http://jsfiddle.net/crustyashish/wSW7z/">演示</a></p> <p><strong>HTML</strong></p> <pre><code><select id="selectMe"> <option value="multiple">multiple</option> <option value="programming">Programming</option> </select> <br><br><br> <div id="multiple" class="group" > Multiple </div> <div id="programming" class="group" > Programming </div> </code></pre> <p><strong>JS</strong></p> <pre><code>$(document).ready(function () { $('.group').hide(); $('#multiple').show(); $('#selectMe').change(function () { $('.group').hide(); $('#'+$(this).val()).show(); }) }); </code></pre> </answer> <answer tick="false" vote="1"> <p>在您的 <pre><code>select</code></pre> <pre><code>option</code></pre> 中,您使用的是 <pre><code>click</code></pre> 而不是 <pre><code>onclick</code></pre> <pre><code>event</code></pre></p> <pre><code><select name="questiontype"> <option name="questiontype" value="multiple" onclick="return showMultiple();">Multiple Choice</option> <option selected name="questiontype" value="programming" onclick="return showProgramming();">Programming< /option> </select> </code></pre> <p>并且无需对单引号使用转义,</p> <pre><code><div id='multiple' style="display:none"> Multiple </div> <div id='programming' style="display:none"> Programming </div> </code></pre> <p>并在 <pre><code>script</code></pre> 标签中</p> <pre><code>$('select[name="questiontype"]').change(function(){ </code></pre> </answer> <answer tick="false" vote="0"> <p>试试这个:</p> <pre><code><form action="addQuestion.php" method="post"> <select name="questiontype" id="questiontype"> <option value="multiple">Multiple Choice</option> <option selected value="programming">Programming</option> </select> <br> <div id='multiple' class="group" style="display:none"> Multiple </div> <div id='programming' style="display:none" class="group"> Programming </div> </form> </code></pre> <p>将此代码放在头部:</p> <pre><code><script src="jquery-1.9.1.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('.group').hide(); $('#programming').show(); $('#questiontype').change(function () { $('.group').hide(1000); $('#'+$(this).val()).show(1000); }) }); </script> </code></pre> </answer> <answer tick="false" vote="0"> <pre><code> <script type="text/javascript"> $(document).ready(function () { $('.group').hide(); $('#programming').show(); $('#questiontype').change(function () { $('.group').hide(1000); $('#'+$(this).val()).show(1000); }) }); </script> </code></pre> </answer> </body></html>
使用 JS 或 jQuery 强制将 HTML 输入字段中的空格转换为 %20 [重复]
我的网站上有一个输入字段,人们可以输入搜索词。 我正在获取用户输入的值并将其吐出到 url 字符串中。 jQuery("#searchButton").click(function(){ ...
$(document).ready() 中的函数调用 vs $(document).ready(function() {})
我正在使用displayRows()函数使用document.ready添加表格主体。它的语法工作正常: $(document).ready(function() 如下 '$(文档).ready(函数() { 函数显示行...
如何创建具有预定义格式的输入字段,其中用户只能输入字段的特定部分
我有一个基本的 HTML 输入字段(用于电话号码),当前允许用户在其中输入并提交他们想要的任何内容: 923-98-我爱小猫:3 但是,我希望该字段看起来像这样: +...
当我单击按钮时,此函数会向我的按钮添加一个旋转类。该按钮上有一个箭头,指向面板滑动的方向。 当我单击...时,如何删除轮换的班级?
我在 stackoverflow 上搜索过,但似乎找不到我想要的东西。我正在寻找一个简单的 jQuery 选项卡部分。 1 个选项卡控制多个内容区域(而不是标准...
我有一个使用 sweetalert.js 的 Laravel 5.8 项目。 我有一个这样的表格: @csr... 我有一个使用 sweetalert.js. 的 Laravel 5.8 项目 我有一个这样的表格: <form id="myForm" action="{{ route('acceptWallet') }}" method="POST"> @csrf <input type="checkbox" id="btn-submit" name="wallet_checked" onchange="this.form.submit();"> </form> 如您所见,我使用了 onchange="this.form.submit();" 来提交表单,而没有使用提交按钮,并且效果很好。 然后通过使用此脚本,我尝试显示 SweetAlert 确认消息框,其中包含 Yes 和 No 作为按钮: $(document).on('click', '#btn-submit', function(e) { e.preventDefault(); let form = $(this).parents('form'); swal( { title: "Attention!", text: "Are you sure you want to make this transaction", type: "warning", allowEscapeKey: false, allowOutsideClick: false, showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes", cancelButtonText: "No", showLoaderOnConfirm: true, closeOnConfirm: false }).then((isConfirm) => { if (isConfirm) { document.getElementById("myForm").submit(); return true; } return false; }); }); 现在它工作正常,但唯一的问题是,当我单击No按钮(即CancelButton)时,它仍然提交表单并调用操作。 所以问题是,当用户按下 No 按钮时,如何拒绝 submit()? 将代码更改为: $(document).on('click', '#btn-submit', function(e) { e.preventDefault(); let form = $(this).parents('form'); swal( { title: "Attention!", text: "Are you sure you want to make this transaction", type: "warning", allowEscapeKey: false, allowOutsideClick: false, showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes", cancelButtonText: "No", showLoaderOnConfirm: true, closeOnConfirm: false }).then((isConfirm) => { if (isConfirm === true) { document.getElementById("myForm").submit(); } }); }); 试试这个代码: $(document).on('click', '#btn-submit', function(e) { e.preventDefault(); let form = $(this).parents('form'); swal( { title: "Attention!", text: "Are you sure you want to make this transaction", type: "warning", buttons: { cancel: 'No', defeat: { text: 'Yes', value: true } }, closeOnConfirm: false }).then((isConfirm) => { if (isConfirm === true) { document.getElementById("myForm").submit(); } }); }); 首先,您需要在要使用 SweetAlert 触发的表单上设置标志: <form id="myForm" action="{{ route('acceptWallet') }}" method="POST" data-flag="0"> @csrf <input type="checkbox" id="btn-submit" name="wallet_checked"> <input type="submit" value="Submit"> </form> 然后你用JS触发它: const form = $('#myForm'); form.submit(function(e) { if (form.attr('data-flag') == 0) { e.preventDefault(); Swal.fire({ title: 'Attention!', text: 'Are you sure want to make this transaction', icon: 'warning', confirmButtonText: 'Yes', cancelButtonText: 'No', showCancelButton: true }).then((res) => { if(res.isConfirmed) { form.attr('data-flag', '1'); form.submit(); } }); } }); 如果您点击否,将会阻止提交表单 这样做。 复制此代码 <form class="sldier-form" action="{{ route('sliders.destroy', $slider->id) }}" method="post"> @csrf @method('DELETE') <button type="button" class="btn btn-danger btn-sm " onclick="sliderDelete()">delete</button> </form> // jquery 脚本 <script> function sliderDelete() { Swal.fire({ title: 'Are you sure?', text: "You won't be able to revert this!", type: 'warning', showCancelButton: true, customClass: { confirmButton: 'btn btn-success', cancelButton: 'btn btn-danger' }, buttonsStyling: false, confirmButtonText: 'Yes, delete it!' }).then((result) => { if (result.value == true) { $('.sldier-form').submit(); Swal.fire( 'Deleted!', 'Your file has been deleted.', 'success' ) } }) } </script> 与 ASPNet MVC 一起使用:- Swal.fire({ title: 'Title of the sweetalert ?', text: 'I'm using SweetAlert 2', icon: 'info', confirmButtonColor: '#3085d6', showCancelButton: true, cancelButtonColor: '#d33', confirmButtonText: 'Yes', cancelButtonText: 'No' }).then((isConfirm) => { console.log(isConfirm); if (isConfirm.isConfirmed === true) { //Logic in case the user hits Yes button } });