Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/24/2021 in all areas

  1. If you assign a jQuery result to a variable, you do not need the $() function to use it. This should work, though I haven't tested it so there might be a mistake somewhere. ( function( $ ) { var modal = $('#myModal'); var img = $('.myImg'); var modalImg = $('#img01'); var captionText = $("#caption"); img.click(function(){ modal.show(); modalImg.attr("src", $(this).attr("src")); captionText.html($(this).attr("alt")); }); var span = $(".close").first(); span.click(function(){ modal.hide(); }); } ( jQuery ) ); I do not see any good reason to convert Javascript to jQuery. jQuery is far less efficient and isn't natively built into browsers, requiring a download of an external file before it can run.
    1 point
×
×
  • Create New...