javascript - Use JS to show images dependant on element class -



javascript - Use JS to show images dependant on element class -

i want show set of logos when searches product in specific category. logo image element hidden (display none) , have class category id. category determines logo gets shown. html 1 logo is:

<li id="show-logo" style="display: none;"> <!-- playtex logo --> <img src="/images/logos/playtex.jpg" class="cat_1"> </li>

so function should follows:

showpartnerlogos(element, cat_id); function showpartnerlogos(element, cat_id) { // show images class cat_id element }

i havent done code because js dismal, function beingness used show modal when searches product:

$('#modal .spinner').spin('flower', 'black'); // loop through selected categories $("#form_buy input[name='buy_product']:checked").each(function() { $('#modal').find('.cat_' + $(this).val() ).show(); }); settimeout(function() { document.location.href = $(form).attr('action'); },0);

this function shows logos in modal, want able same except display logo on page.

try this

function showpartnerlogos(element, cat_id) { // show images class cat_id element $(element + '.' + cat_id).show(); }

this display img elements class sent in cat_id.

ideally not require parameter element show img tags above code can used hide type of element preovided pass tag name in parameter element

function showpartnerlogos(cat_id) { // show images class cat_id element $('img.' + cat_id).show(); }

please allow me know if helped.

javascript jquery html css

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -