CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   jQuery object with variable id name. Is is possible? (http://www.codingforums.com/showthread.php?t=151219)

FunkyORACLE 10-30-2008 11:54 AM

jQuery object with variable id name. Is is possible?
 
Hi,
is it possible to passed the jQuery object a variable with the the js functions for example?
I'm having problems with jQuery. I have an img that on click it runs this function however nothing gets hidden or shown.

I have the following in my page header

Code:

function hide_Show(RegionID)
  var $jQuery = jQuery.noConflict();
//Icon that is clicked
  var objectClickedID = '#' + RegionID + '_img';
//Region to hide
  var objectID = '#' + RegionID;
  $jQuery(document).ready(function(){
      $jQuery(objectClickedID).click(function() {
        if ($x(objectID).style.display =='none') {
          $jQuery(objectID).show('slow');
        }
        else{
          $jQuery(objectID).hide('slow');
        }
      });
}

and my img is as following

Code:

<img id="show_hide_img" onClick ="hide_Show('show_hide'):" alt="Click here to expand/collapse this section" style="cursor: pointer;" src"plus.gif" />
and my region that I want to hide is
Code:

<div id="show_hide">Hide this</div>
I know you might say that I could just hard code the div ID though I have a lot of divs and they img's need to hide specifc divs.


Thanks for your support.


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.