2016-04-29 56 views
-2

如果我有一个带冒号的标识符id=cu:w,我怎么能用jQuery选择它?在jQuery中选择一个ID属性冒号的元素

$(function() { 
 
    $('#cu:w').on('change', function() { 
 
    $(this).hide(); 
 
    }); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<fieldset> 
 
    <legend>Check Here 
 
    <input id='cu:w' type="checkbox"> 
 
    </legend> 
 
    <span class="myClass"> 
 
      <p>This is the text.</p> 
 
     </span> 
 
</fieldset>

回答