c#
  • jquery
  • asp.net
  • 2013-11-17 2 views 1 likes 
    1

    Я хочу скрыть теги типа ввода с атрибутом keep-current-customize = "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> 
    

    ответ

    3

    не записывайте .attr к примеру:

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

    jsFiddle example

    +0

    это тоже работает, но мне нужно удалить div с id textgrid, который внутри содержит входной тег с атрибутом keep-current-customization = false Что мне нужно делать в этом случае? –

    +1

    сделать так: пример (". Textgrid"). Имеет ("input [keep-current-customization = 'false']"). Hide(); http://jsfiddle.net/Pascalz/3z4WT/1/ – Pascalz

    +0

    За исключением символа хеша, а не периода, поскольку он является идентификатором, а не классом – pwdst

    1

    Попробуйте это: функция

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

    Нет атр() необходимо для выбора элементов в этом случае.

    +0

    это работает, но мне нужно, чтобы удалить DIV с идентификатором textgrid, который действительно содержит атрибут keep-current-customization = false Что мне нужно сделать в этом случае? –

    +0

    Вы можете использовать select() для дополнительной фильтрации, например «div: has (input [keep-current-customization = false])» выбирает все div с входами. И затем спрячьте те divs. –

    3

    Функция attr() устанавливает или получает значения атрибутов для заданных элементов. Для того, чтобы найти элементы с определенным значением атрибута, попробуйте следующее:

    $("input[keep-current-customization='false']").hide(); 
    
    Смежные вопросы