使用关联的属性隐藏输入标记

时间:2013-11-17 10:48:53

标签: c# jquery asp.net

我想隐藏输入类型标签,其属性为 keep-current-customization =“false”。我的代码是:

var example = jQuery.noConflict();
example(function () {
    example.attr("input[keep-current-customization='false']").hide();
});

但它不起作用。

以下是信息源在页面上的显示方式:

  <h3>Current Carrier Questionnaire<strong style="color: Red;"></strong></h3>

  <div class="desc">
      To keep your current home phone number,  please complete the below.</div>
  <br />

  <div class="textgrid">
       <div class="feildset1">
            Account holders name on your current phone bill?: </br>
            <input name="rptCustomization$ctl07$rptItems$ctl00$ctrl" type="text" maxlength="100" id="rptCustomization_rptItems_7_ctrl_0" keep-current-customization="false" /></br>
           <br />
       </div>
   </div>

   <div class="textgrid">
        <div class="feildset1">
             Current phone company you have?: </br>
             <input name="rptCustomization$ctl07$rptItems$ctl01$ctrl" type="text" maxlength="100" id="rptCustomization_rptItems_7_ctrl_1" keep-current-customization="false" /></br>
             <br />
        </div>
    </div>

    <div class="textgrid">
         <div class="feildset1">
              What is the account # with your current provider?: </br>
              <input name="rptCustomization$ctl07$rptItems$ctl02$ctrl" type="text" maxlength="100" id="rptCustomization_rptItems_7_ctrl_2" keep-current-customization="false" /></br>
              <br />
         </div>
    </div>

    <div class="textgrid">
         <div class="feildset1">
              What is the PIN/access code for current provider?: </br>
              <input name="rptCustomization$ctl07$rptItems$ctl03$ctrl" type="text" maxlength="100" id="rptCustomization_rptItems_7_ctrl_3" keep-current-customization="false" /></br>
              <br />
         </div>
     </div>

     <div class="textgrid">
          <div class="feildset1">
               What are the two nearest cross streets?: </br>
               <input name="rptCustomization$ctl07$rptItems$ctl04$ctrl" type="text" maxlength="100" id="rptCustomization_rptItems_7_ctrl_4" keep-current-customization="false" /></br>
               <br />
           </div>
     </div>

4 个答案:

答案 0 :(得分:3)

var example = jQuery.noConflict();
example(function () {
    example("input[keep-current-customization=false]").hide();
});

在这种情况下,选择元素不需要attr()函数。

答案 1 :(得分:3)

attr()函数设置或获取给定元素的属性值。要查找具有特定属性值的元素,请尝试以下操作:

$("input[keep-current-customization='false']").hide();

答案 2 :(得分:3)

不要将.attr放到示例中:

example("input[keep-current-customization='false']").hide();

jsFiddle example

答案 3 :(得分:1)

试试这个:

$("input[keep-current-customization='false']").hide();