SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Target all images in jQuery

    Hi, I need change the following jQuery script to target all images for a WP theme. I found two codes that may do it, but I don't know where to place them.

    (sample)
    Code JavaScript:
    $("img[src='left1.gif']").hide();
    or
    event.target. As it stands now, the script doesn't load images, the browser takes over and loads the image.


    (I've included the original comments in the script for safe keeping)
    Code JavaScript:
    jQuery(function(){
     
      // Tabs
      jQuery("#fbfwTabs").tabs();
     
    	// Hide Donation and twitter stuff on tabs other than Info
      jQuery("#fbfwTabs li a").click(function(){
    		jQuery("#mfbfwd").hide();
      });
     
    	jQuery("#show-mfbfwd").click(function(){
    		jQuery("#mfbfwd").show();
      });
     
      // Advanced Settings Switcher
      jQuery("#advOpsSwitch").click(function(){
    		jQuery(".advOpts").toggle("slow");
      });
     
      // Troubleshooting & Settings Switcher
      jQuery("#troOpsSwitch").click(function(){
    		jQuery(".troOpts").toggle("slow");
      });
     
      // Hide Custom Expresion textarea if not needed
      var galleryType = jQuery("input:radio[name=mfbfw_galleryType]:checked").val();
     
      switch (galleryType) {
    	case "all":
    	case "none":
    	case "post":
    	  jQuery("#customExpressionBlock").css("display", "none");
      }
     
      jQuery("#mfbfw_galleryTypeAll").click(function () {
    	jQuery("#customExpressionBlock").hide("slow");
      });
     
      jQuery("#mfbfw_galleryTypePost").click(function () {
    	jQuery("#customExpressionBlock").hide("slow");
      });
     
      jQuery("#mfbfw_galleryTypeCustom").click(function () {
    	jQuery("#customExpressionBlock").show("slow");
      });
     
    })

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You can place it anywhere within the jQuery DOM ready function
    Code JavaScript:
    jQuery(function() {
        jQuery("img[src='left1.gif']").hide();
    });

  3. #3
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code you posted looks like it will only work for an image named 'left1.gif' what about all images in any post, isn't there some wildcard you can use ? When you say DOM selector do you mean I can place it anywhere within the script, I haven't gotten up to speed with DOM yet !

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Sorry i misinterpreted what you were asking in your original question, would the script be hiding all the images on the page or only specific images you want?

  5. #5
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script / add-on would be triggering all the images and hiding none.

  6. #6
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Correct me if I'm wrong but is what your wanting a lazy loader so the images only load when you scroll down the page?

  7. #7
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The script should execute for all images, jpeg, png etc as that is it's purpose. At this point it's not working why I want to do this change so it works again

  8. #8
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SgLegend. The script did work on older versions of WP where as all images once clicked would load in a window. For a few versions of WP it hasn't worked and I enjoy this image viewer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •