View Full Version : jQuery object with variable id name. Is is possible?

Oct 30th, 2008, 11:54 AM
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

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

and my img is as following

<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

<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.