大佬教程收集整理的这篇文章主要介绍了遇到jQuery的问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
从我可以看到icheck插件为表单样式添加额外的div元素,所以似乎添加一个额外的父()将解决问题.它有点乱,但这是我能做的最好的,因为我正在使用的小部件是动态引入的.
可以在这里找到实例:http://bvp.dmediastudios.com和没有icheck(有效)的版本在这里http://bvp.dmediastudios.com/v4/
代码如下:
$('.frmInput input[type=radio]').click(function () { // buy or lease options,have to seperate functions for each option since the html structure is different for each one so a all size fits solution using parent() is not possible (that I kNow of) - very lame. BETTER DONE THAN PERFECT! if ($('.frmInput input[type=radio]').is(':checked')) { // parent(1) = #harwidget,parent(2) = #homefinderform,parent(3) .frmRow - find .frmLabel $(this).parent().parent().parent().parent().find('.frmLabel').addClass('frmLabelchecked'); } });
复选框代码
$('#divBuyType').on('click','input:checkBox',function () { $(this).parent().parent().parent().parent().find('.frmLabel').toggleClass('frmLabelchecked',this.checked); });
可在此处找到非工作版本:bvp.dmediastudios.com,可在此处找到工作版本(不带icheck):bvp.dmediastudios.com/v4/
这是上面函数引用的html块
<div id="mywidget3A0A581997704AA41EB19FFEC804E593" style="text-align:left;"> <div style="width:450px;height:520px;" id="widgetOuter"> <div id="widgetContainer"> <div class="widgetHeader" style="display: none;"> <div class="widgetright"> <div class="widgetMidd"> <div class="widgettitle">Home Finder</div> <div class="widgetBACkBtn" id="hartab3A0A581997704AA41EB19FFEC804E593" style="display:none;"> <img src="" onclick="showSearch('3A0A581997704AA41EB19FFEC804E593')" style="cursor:pointer;"> </div> <div class="titleBar" id="titleBar3A0A581997704AA41EB19FFEC804E593"></div> </div> </div> </div> <div class="widgetBody"> <span id="widgetBodyDiv" style="height:438px;" onscroll="fixTip('3A0A581997704AA41EB19FFEC804E593');"> <div id="harwidget3A0A581997704AA41EB19FFEC804E593" style="padding: 10px; display: block;"> <form name="homefinderform" method="get" class="forms" id="homefinderform"> <div class="frmRow"> <div class="frmLabel">Buy or Lease :</div> <div class="frmInput"> <span> <div class="iradio_minimal-grey checked" style="position: relative;"> <input type="radio" name="For_SALE" value="1" checked="" onclick="showBuyDiv(this)" class="radioButton" style="position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Buy</span> <span>-</span> <span> <div class="iradio_minimal-grey" style="position: relative;"> <input type="radio" name="For_SALE" value="0" onclick="showLeaseDiv(this)" class="radioButton" style="position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Lease</span> </div> </div> <div class="frmRow"> <div class="frmLabel">Property Type</div> <div class="frmInput"> <div id="divBuyType"> <span> <div class="icheckBox_minimal-grey checked" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="1" type="checkBox" style="width: 20px; position: absolute; opacity: 0;" checked=""> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Single Family Homes <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="2" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Townhouse/Condo <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="6" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Highrise Condominium <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="3" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Residential Lots & Land <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="4" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Multi-Family <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROPERTY_CLASS_ID" value="5" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Homes and/or Acreage</span> </div> <div id="divLeaseType" style="display:none;"> <span> <div class="icheckBox_minimal-grey checked" style="position: relative;"> <input name="PROP_TYPE" value="'SGL'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;" checked=""> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Single Family Homes <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROP_TYPE" value="'THC'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Townhouse/Condo <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROP_TYPE" value="'HIR'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Highrise Condominium <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROP_TYPE" value="'LOT'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Residential Lots & Land <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROP_TYPE" value="'MLT'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Multi-Family <div class="br"> <br> </div> <div class="icheckBox_minimal-grey" style="position: relative;"> <input name="PROP_TYPE" value="'ACR'" type="checkBox" style="width: 20px; position: absolute; opacity: 0;"> <ins class="icheck-Helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; BACkground-color: rgb(255,255); border: 0px; opacity: 0; BACkground-position: initial initial; BACkground-repeat: initial initial;"></ins> </div>Homes and/or Acreage <div class="br"> <br> </div> </span> </div> </div> </div> <!--Start SELEct Fields-->
以上是大佬教程为你收集整理的遇到jQuery的问题全部内容,希望文章能够帮你解决遇到jQuery的问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。