You need to sign in to do that
Don't have an account?
Kyle Mathis 7
Can't get JQuery on Click to function properly
Here's the code. The flip works just fine but no dice on the click. It works in code pen/js fiddle etc. I just can't get it all to fire off in VF page. This isn't the entire code but this is where the issue is. If this part would run we'd be gravy.
<html>
<head>
<apex:stylesheet value="{!$Resource.TilesStyles}" />
<script src="//code.jquery.com/jquery-3.2.1.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$('.hover').hover(function(){
$(this).addClass('flip');
},function(){
$(this).removeClass('flip');
});
});
$("#additionalDivOne").on("click", function(){
alert('this is not working');
});
<html>
<head>
<apex:stylesheet value="{!$Resource.TilesStyles}" />
<script src="//code.jquery.com/jquery-3.2.1.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$('.hover').hover(function(){
$(this).addClass('flip');
},function(){
$(this).removeClass('flip');
});
});
$("#additionalDivOne").on("click", function(){
alert('this is not working');
});
This works perfectly well for me:
Additinnally, you can bind yourself to the document instead of the element itself if you know it will not have been rendered yet like so: