Here is a JQuery code snippet to get the clicked div elements's attribute or the value with the similar class names on click function
<script>
$(document).ready(function(){
$('.simg').click(function(){
//var pth = $('.simg').attr('src');
var pth = $(this).attr('src');
console.log(pth);
});
});
</script>
JQuery Detect the browser window top and change CSS on page
JQuery Detect the browser window top and change CSS on page
var t = $("#nav2").offset().top;
$(document).scroll(function() {
if ($(this).scrollTop() > t)
{
$('#nav2').css('position', 'fixed');
$('#nav2').css('top', '0');
}
else
{
$('#nav2').css('position', 'relative');
}
});
var t = $("#nav2").offset().top;
$(document).scroll(function() {
if ($(this).scrollTop() > t)
{
$('#nav2').css('position', 'fixed');
$('#nav2').css('top', '0');
}
else
{
$('#nav2').css('position', 'relative');
}
});
Subscribe to:
Posts (Atom)