How to disable click on .lg-img-wrap?
I have tried lot of solutions but none seems to work on lightgallery.
Tried 1
$(".lg-img-wrap").children().unbind('click');
Tried 2
$(".noclick").click(function(e) {
e.preventDefault();
e.stopPropagation();
});
Tried 3
pointer-events:none //to a css property
I would like to prevent closing of light gallery when user clicks outside the image.
Black margin is visible when image ratio is not same as that of screen size.
Please check image below for reference.
Light Gallery I am using: https://github.com/sachinchoolur/lightGallery
Add closeable: false to your lightGallery initialization. Here's their API describing that feature.
Working Codepen
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.10.0/css/lightgallery.css" integrity="sha512-I/g40Mx7U2Oepd3iHIpQRqdQGJ3vgdw0ix8LxGxX9zKv1MDizjD6dRcJ3PC1qpyfkj4rikVNcpBKcnmuJWUaTQ==" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.10.0/js/lightgallery.min.js"></script>
</head>
<div id="lightgallery">
<a href="https://via.placeholder.com/150">
<img src="https://via.placeholder.com/150" />
</a>
</div>
<script type="text/javascript">
$('#lightgallery').lightGallery({
closable: false
});
</script>
</html>
$(".lg-img-wrap").off("click");
or
$(".lg-img-wrap").prop("disabled",true);
or
$('.lg-img-wrap"').click(false);
I hope it works for you. good work.
Related
I've tried to make the dialog modal option work for quite a while now, but still haven't figured out what went wrong and why it isn't working for me.
Tried looking at other posts on stackoverflow and the dialog widget page on the official jQueryUI website, but i still can't solve it.
Here are my codes:
<link type="text/css" rel="stylesheet" href="JQueryUI-1.12.1/jquery-
ui.css"
<link type="text/css" rel="stylesheet" href="JQueryUI-1.12.1/jquery-
ui.structure.css">
<link type="text/css" rel="stylesheet" href="JQueryUI-1.12.1/jquery-
ui.theme.css">
</head>
<body>
<div id="container">
<div id="messageBox" title="Message">
<p> Thank you for visiting our website </p>
</div>
</div>
<script src="JQuery-3.3.1-Library.js"></script>
<script src="JQueryUI-1.12.1/jquery-ui.js"></script>
<script>
$("document").ready(function(){
$("#messageBox").dialog({show: {effect: "bounce", duration:1500}})
.dialog({hide: {effect: "explode", duration:1500}})
.dialog({closeOnEscape: false})
.dialog({modal:true});
</script>
</body>
Hoping that someone would help me.
I recommend cdn instead of local files (this isn't fix your problem, but possibly come with some benefits, read this for more info, and you missed one "});"
I tested this code and it worked normally, check if you have any errors on your chrome console and tell us if you have
<body>
<div id="container">
<div id="messageBox" title="Message">
<p> Thank you for visiting our website </p>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<script>
$("document").ready(function () {
$("#messageBox").dialog({
show: {
effect: "bounce",
duration: 1500
}
})
.dialog({
hide: {
effect: "explode",
duration: 1500
}
})
.dialog({
closeOnEscape: false
})
.dialog({
modal: true
});
}); // you missed this
</script>
Upon clicking the image, I want the image to pop out and show message. But i don't know how to do it.
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/lightbox.min.js"></script>
<link href="css/lightbox.css" rel="stylesheet">
<a href="Images/royalpalace.jpg" data-lightbox="image-1" data-title="RoyalPalace">
<img src="Images/royalpalace.jpg" width="19.7%" height="200px">
</a>
You need to link the appropriate files in the given order:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.10.0/js/lightbox.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.10.0/css/lightbox.min.css" rel="stylesheet">
And make sure the image paths are valid.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.10.0/js/lightbox.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.10.0/css/lightbox.min.css" rel="stylesheet">
<a href="https://cdn.pixabay.com/photo/2015/08/11/10/41/royal-palace-883800_960_720.jpg" data-lightbox="image-1" data-title="RoyalPalace">
<img src="https://cdn.pixabay.com/photo/2015/08/11/10/41/royal-palace-883800_960_720.jpg" width="200px">
</a>
Here is one way to do it:
First, move the <img> out of the <a> tag, or else it will redirect the user to another page, then to pop the image out, write this in a js script:
document.getElementsByTagName("img")[0].addEventListener("click", function () {
this.style.display = "none";
alert("Your message here");
})
You can enhance this by giving the <img> an id attribute and then using document.getElementById("<Your img id>") to access it.
I'm using Foundation 5 magellan navigation but smooth scroll doesn't work. In example all is fine: http://foundation.zurb.com/docs/components/magellan.html
My code: http://jsfiddle.net/5LKzf/
<head>
<link rel="stylesheet" href="css/foundation-5.2.2/css/foundation.css" />
<link rel="stylesheet" href="css/foundation-5.2.2/css/normalize.css" />
<script src="css/foundation-5.2.2/js/vendor/modernizr.js"></script>
</head>
<body>
//my link
<li class="item-109 menu-el active"><dd data-magellan-arrival="/"><a href="#/" >Main Page</a></dd></li>
//my anhor
<a class="link-pos" data-magellan-destination="/" name="/"> </a>
<script src="css/foundation-5.2.2/js/vendor/jquery.js"></script>
<script src="css/foundation-5.2.2/js/vendor/fastclick.js"></script>
<script src="css/foundation-5.2.2/js/foundation.min.js"></script>
<script>
$( document ).foundation();
</script>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/main.js"></script>
</body>
Did I forget to include any files?
According to the docs
"Make sure jquery.js, foundation.js, and foundation.magellan.js have been included on your page before continuing. For example, add the following before the closing tag:"
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.magellan.js"></script>
According to the code you posted, you are missing the magellan js, which would explain why it doesnt work!
I have worked with Foundation 5, and with some features you need to ensure you include the relevant javascript.
I hope this helps!
I'm attempting to use a fancy JSslider, with a project I'm working on for school and I can't seem to understand why I can't get it working. It should be simple...
<link href='http://fonts.googleapis.com/css?family=Merienda One' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="coin-slider.min.js"></script>
<div id="wTurkey">
<h1> The Wild Turkey</h1>
<div class="coin-slider">
<a href="" target="_blank">
<img src='images/cotside.jpg'>
<span>
<p>The Wild Turkey</p>
Some text here
</span>
</a>
At the very end of my body tag I have the following
<script type="text/javascript">
$(document).ready(function() {
$('#coin-slider').coinslider({hoverPause: false });
});
</script>
</body>
Here's the original site. http://workshop.rs/2010/04/coin-slider-image-slider-with-unique-effects/ I'm just basicly looking for a second set of eyes to tell me what's wrong.
The problem is with your jQuery selector:
$('#coin-slider')
should be
$('.coin-slider')
The 'dot' denotes a css class rather than an ID (which is denoted by the # symbol)
I actually make a homepage. My login-area is in an Iframe, hereĀ“s my code:
<link type="text/css" media="screen" rel="stylesheet" href="colorbox.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="colorbox/jquery.colorbox.js"></script>
<script>
$(document).ready(function(){
$(".example7").colorbox({width:"85,5%", height:"85%",iframe:true});
});
and
<button>Klick</button>
My problem is, that I want the new link not to open in the iframe-window.
How can I do that?
... will open the link in a new page.
See also: https://developer.mozilla.org/en/HTML/Element/a#attr-target