![](/img/trans.png)
[英]In React Js I want to try to open modal after clicking on card but the modal is not open after clicking on card
[英]Running JS AFTER Modal is open
我嘗試了很多方法,例如:
$(document).ready(function () {
$('body.modal-open').on('shown.bs.modal', function (e) {
if ($("a.address").length) {
var signupText = (hightestCount);
$(".rg-modal-signup h2").text('Keep searching ' + signupText + ' real estate.');
} else {
var signupText = '';
$(".rg-modal-signup h2").text('Keep searching for your dream home.');
}
}); });
和:
$('body.modal-open').on('shown', function(){
if ($("a.address").length) {
var signupText = (hightestCount);
$(".rg-modal-signup h2").text('Keep searching ' + signupText + ' real estate.');
} else {
var signupText = '';
$(".rg-modal-signup h2").text('Keep searching for your dream home.');
} });
只是不起作用,我似乎只能在按鈕提示模態時使其運行代碼,但當模態以不同方式顯示時則不行。 有什么建議么?
給你的模態一個 id 並嘗試使用 JQuery's:visible 方法。
if($('#modal').is(":visible")){
if ($("a.address").length) {
var signupText = (hightestCount);
$(".rg-modal-signup h2").text('Keep searching ' + signupText + ' real estate.');
} else {
var signupText = '';
$(".rg-modal-signup h2").text('Keep searching for your dream home.');
}
}
如果你堅持使用boostrap的方法
$(document).ready(function () {
$('body').on('shown.bs.modal', function (e) {
if ($("a.address").length) {
var signupText = (hightestCount);
$(".rg-modal-signup h2").text('Keep searching ' + signupText + ' real estate.');
} else {
var signupText = '';
$(".rg-modal-signup h2").text('Keep searching for your dream home.');
}
}); });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.