javascript - jQuery doesn't display specific hidden content when I use the .show() command -


below html , jquery code. jquery displays hidden elements, except #image4 , #video4 elements, stay hidden if select image or video. other elements displayed correctly.

any idea why 2 won't show?

js:

 $(document).ready(function(){         var fields = jquery('#image_type');         var select = this.value;         fields.change(function () {             if ($(this).val() == 'image') {               alert($(this).val());                 $('#images_pop_up').show();                 $('#video1').hide();                 $('#video2').hide();                 $('#video3').hide();                 $('#video4').hide();                 $('#image1').show();                 $('#image2').show();                 $('#image3').show();                 $('#image4').show();                 $(' #image5').show();               }               else {                 $('#images_pop_up').show();                 $('#image1').hide();                 $('#image2').hide();                 $('#image3').hide();                 $('#image4').hide();                 $('#image5').hide();                 $('#video1').show();                 $('#video2').show();                 $('#video3').show();                 $('#video4').show();                 $('#image5').show();               }          });     }); 

html:

<div id ="images_pop_up" style="display:none;">    <span id="image1"  style="display:none;" ><img src="/uploads/commerce/images/large/easton-163135-wheeled-bag.jpg" border="0" alt="easton-163135-wheeled-bag.jpg" title=" easton-163135-wheeled-bag.jpg " class="productimage"><input type="hidden" name="products_previous_image_lrg" value="easton-163135-wheeled-bag.jpg"><br>nice bag</span>    <span  id ="video1" style="display:none;"></span></td>    <td  class="textsmall" valign="top">       <table border="0" cellpadding="0" cellspacing="0" width="100%">          <tr>             <span id="image3"  style="display:none;"><input type="hidden" name="products_previous_image_lrg" value="easton-163135-wheeled-bag.jpg"><input type="hidden" name="products_previous_image_lrg_caption" value="nice bag"></span>             <span id ="video3"><input type="hidden" name="products_previous_video_embed"><input type="hidden" name="products_previous_video_embed_caption"></span>             <td class="textsmall" valign="top"><span id="image4" style="display:none;">new image file: <input type="text" name="products_image_lrg" value="easton-163135-wheeled-bag.jpg"><br>image caption: <input type="text" name="products_image_lrg_caption" value="nice bag"></span>                <span id ="video4" style="display:none;">video embed field: <input type="text" name="products_video_embed"><br>video image caption: <input type="text" name="products_video_embed_caption"></span>             </td>             <td><span id="image5" style="display:none;"> <a href='#' onclick='return false;'><img src="includes/languages/english/images/buttons/button_select.gif" border="0" alt="select" title=" select " onclick="popupwindowselectimg('./images_select.php?imgsize=lrg&inpt=products_image_lrg&div=div_img_lrg&width=200&height=30','lrg','products_image_lrg','div_img_lrg');"></a></span></td>          </tr>          <tr>             <td colspan="2">                <div id='div_img_lrg'></div>             </td>          </tr>       </table>    </td> </div> 

try this

    $(document).ready(function () {     var fields = jquery('#image_type');     var select = this.value;     $('#image_type').change(function () {         if ($(this).val() == 'image') {             alert($(this).val());             $("[id^=image]").show();             $("[id^=video]").hide();         } else {             $("[id^=video]").show();             $("[id^=image]").hide();         }      }); }); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -