<input type="radio" name="active" value="0" />否
<input type="radio" name="active" value="1" />是比如,当点击“是”时,我想取得“是”这个文字该如何做到?

解决方案 »

  1.   

    jQuery(':radio').click(function(){
        alert(this.innerHTML)
    })
      

  2.   


    <script src="js/jquery-1.3.2.js"></script>
    <script>
    window.onload=function(){
      $(':radio').click(function(){ 
         alert($(this)[0].nextSibling.nodeValue) 
      })
    }
    </script>
    <form>
    <input type="radio" name="active" value="0" />否 
    <input type="radio" name="active" value="1" />是
    </form>
      

  3.   

    不好意思,看错了,你怎么把是,和 否 放在那里
    this.nextSibling.nodeValue 
      

  4.   

    alert($(this)[0].nextSibling.nodeValue)为什么这边要加用$(this)[0],而不直接用$(this)?
      

  5.   

    用于跳出jquery闭包,得到DOM节点
      

  6.   

    jQuery.fn = jQuery.prototype = {
    init: function( selector, context ) {
    // Make sure that a selection was provided
    selector = selector || document; // Handle $(DOMElement)
    if ( selector.nodeType ) {
    this[0] = selector;
    this.length = 1;
    return this;
    }
    // Handle HTML strings
    if ( typeof selector == "string" ) {
    // Are we dealing with HTML string or an ID?
    var match = quickExpr.exec( selector ); // Verify a match, and that no context was specified for #id
    if ( match && (match[1] || !context) ) { // HANDLE: $(html) -> $(array)
    if ( match[1] )
    selector = jQuery.clean( [ match[1] ], context ); // HANDLE: $("#id")
    else {
    var elem = document.getElementById( match[3] ); // Make sure an element was located
    if ( elem ){
    // Handle the case where IE and Opera return items
    // by name instead of ID
    if ( elem.id != match[3] )
    return jQuery().find( selector ); // Otherwise, we inject the element directly into the jQuery object
    return jQuery( elem );
    }
    selector = [];
    } // HANDLE: $(expr, [context])
    // (which is just equivalent to: $(content).find(expr)
    } else
    return jQuery( context ).find( selector ); // HANDLE: $(function)
    // Shortcut for document ready
    } else if ( jQuery.isFunction( selector ) )
    return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector ); return this.setArray(jQuery.makeArray(selector));
    }
    jquery对象是dom element的数组。谢谢hookee!
      

  7.   

    <input type="radio" name="active" value="1" onclick="alert(this.firstChild.nodeValue)"/>是 
      

  8.   

    <input type="radio" name="active" value="1" onclick="alert(this.nextSibling.nodeValue)"/>是
    测试通过