Failed in jquery mouseover/hover

Discussion in 'Programming' started by jaylimix, May 9, 2012.

to remove all ads.
  1. jaylimix

    jaylimix New Member

    Messages:
    7
    Im unable to change the "My available bids" number 50 to become "Buy". Tried several ways using mouseover/hover but failed. Thanks for help in advance.:)

    HTML:
    
    <div id="welcome" align="right">
        
        <?php
            $username= $_SESSION['username'];
            echo "Welcome ".$username."<p/>";
        ?>
        My Available Bids:
        <div id="available_bids">
            <a href="#">
                <?php
                    include "connect.php";
    
                    $query= "SELECT * FROM member WHERE username= '$username'";
                    $result= mysql_query($query);
                    $record= mysql_fetch_object($result);
                    $available_bids= $record->available_bids;
                    echo $available_bids;
                ?>
            </a>
        </div>
        <br/>
        <div id="my_profile"><a href="#">My Profile</a></div>
        <br/>
        <a href="logout.php" id="sign_in">Logout</a>
    </div>
    
    <script src="jquery.js"></script>
    
    <script src="text/javascript">
        
        $(document).ready(function(){
            
            $('#available_bids').hover(function(){
           
            $(this).text("Buy");
           
            });
        });
        
        
    </script>
    
     

    Attached Files:

  2. Phreaddee

    Phreaddee Super Moderator Staff Member

    Messages:
    1,978
    HTML:
    <script type="text/javascript">
    $('#available_bids').contents().each(function() {     
    if(this.nodeType == 3)         
    this.nodeValue = this.nodeValue.replace("50", "Buy"); 
    }
    );
    </script>
    
    ???
     
  3. jaylimix

    jaylimix New Member

    Messages:
    7
    It doesnt work. Okay here's the exact code I typed in.

    HTML:
    <script src="jquery.js"></script>
    
    <script src="text/javascript">
        
        $("#available_bids").mouseover(function(){
            
            $('#available_bids').contents.each(function(){
               if(this.nodeType ==3)
                   this.nodeType= this.nodeType.replace("50","Buy");
            });
            
        });
        
        
    </script>
    
    Question. The 50 is not actually static(it changes), could I still use replace like this?
     
  4. Brian Angel

    Brian Angel Member

    Messages:
    248
    Question.. now.. Im assuming from a function standpoint your looking to start at 50 and reduce the number by each bid until 0?
     
  5. jaylimix

    jaylimix New Member

    Messages:
    7
    That's right but I havent wrote that function yet.
     
  6. jaylimix

    jaylimix New Member

    Messages:
    7
    I solve it already. Thread closed.
     

Share This Page