webusercontrol - Multiple instances of user controls with jquery -


i using multiple instances of user control in page. jquery effect first usercontrol , other user controls gets "first user control" design changes.

please how can solve this?

this usercontrol:

jquery

 $(document).ready(function () {          if ($(".subcompanytypes").is(":visible")) {             $(".maincompanytypes").css("width", "240px");             $(".subcompanytypes").css("width", "96px");         }          else         {             $(".maincompanytypes").css("width", "70px");             $(".subcompanytypes").css("width", "96px");         }      });      <asp:dropdownlist id="ddlmaincompanytypes" runat="server" width="342px"  cssclass="maincompanytypes"                     onselectedindexchanged="ddlmaincompanytypes_selectedindexchanged"                     autopostback="true">                     <asp:listitem text="-select-" value="" />                 </asp:dropdownlist>     <asp:dropdownlist id="ddlsubcompanytypes" runat="server" width="300px" visible="false"  cssclass="subcompanytypes"                     autopostback="true"  onselectedindexchanged="ddlsubcompanytypes_selectedindexchanged">                 </asp:dropdownlist> 

try one:

$(document).ready(function () { $(".subcompanytypes").each(function(){     if ($(this).is(":visible")) {            // $(".maincompanytypes").css("width", "240px");            // .maincompanytypes check previous control , apply css              $(this).prev('.maincompanytypes').css("width", "240px");              $(this).css("width", "96px");         }         else         {            // $(".maincompanytypes").css("width", "70px");               $(this).prev('.maincompanytypes').css("width", "70px");               $(this).css("width", "96px");         }     }); }); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -